https://sourceforge.net/apps/mediawiki/ ... title=PyQt
First, for this snippet
Code: Select all
for child in mw.children:
print 'widget name = ', child.getObjectName(), ', widget type = ', child
also, "getObjectName()" is not the name of any method, it should be "objectName()"
further down
Code: Select all
myWidget = QtGui.QDockWidget()
mw.addDockWidget(QtCore.Qt.RightDockWidgetArea,myWidget)
myWidget.setObjectName("my Nice New Widget")
myWidget.resize(QtCore.QSize(QtCore.QRect(0,0,300,100))) # sets size of the widget
label = QtGui.QLabel(myWidget) # creates a label
label.setGeometry(QtCore.QRect(50,50,200,24)) # sets its size
label.setObjectName("myLabel") # sets its name, so it can be found by name
Code: Select all
myWidget.resize(QtCore.QSize(300,100)) # sets size of the widget
Why bother creating a label if you put no text in it?
Code: Select all
label = QtGui.QLabel("Hello World", myWidget) # creates a label
I'm wondering if this is a situation where PyQt API changed significantly since the wiki was written. I'm running FreeCAD .12 revision 4380 (Launchpad), which shows Qt version 4.7.4.
Do these examples run ok on FreeCAD .11 and the wiki is not updated because .12 is not stable yet?
Or have these example been written without ever being tested?
I've run into problems with a few of the other wiki page examples and it's just very frustrating that none of these seem to be tested to actually run at all.