victor wrote:
hello list,

i have encountered an issue that i have reduced to this sample code:

if __name__ == '__main__':
    import sys
    from PyQt4.QtGui import QLabel
    from PyQt4.QtCore import QTimer
    from PyQt4.QtGui import QApplication
    app = QApplication(sys.argv)
    for i in range(3):
        l = QLabel('%d' % i)
        l.show()
    QTimer.singleShot(5000, app.quit)
    app.exec_()

because i'm using the same variable to reference the instances, only one instance remains (the last one) which is not really what i expect.

what is the way to create several widgets in a loop? thanks.

As with any python object, you have to keep at least a reference to each of the generated objects in order to prevent garbage collection.

Armando

_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to