Sunday, 1 November 2009

Using an mdiArea in PyQt


I am adding a notifications area to openmolar, and experimenting with an mdiArea for this.
I couldn't find a nice python (PyQt) example on the web, so offer this for google's sake.
import sys
from PyQt4 import QtCore, QtGui

app = QtGui.QApplication(sys.argv)

mdiArea = QtGui.QMdiArea()
mdiArea.show()

labels = []

for i in range(5):
    labels.append(QtGui.QLabel())
    labels[i].setText("hello world")
    mdiArea.addSubWindow(labels[i])
    labels[i].show()
    
mdiArea.cascadeSubWindows()

sys.exit(app.exec_())

2 comments:

Learn with Me! said...

Thanks for that! Needed that example. I try to document what I do as well, but I'm still a beginner. ^ ^

http://learnwithhelvin.blogspot.com/

Developers Area said...

Hello thanks for tutorial
right now I am working on medium project ...And kind of I am stuck ... I don't know how to add Widgets to QMdiArea Sub window ... I know how to add a Single widget but i Have no idea how to add Multiple Widgets .... Please help me .. I waiting for your answer ....

for more you can check My question inside Stack Over Flow website :
http://stackoverflow.com/questions/37515978/how-to-put-widgets-inside-a-pyqt-qmdisubwindow
thank You