Help with PyQt API (and wiki edit Permissions please)

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
peepsalot
Posts: 50
Joined: Sun Nov 13, 2011 9:44 pm

Help with PyQt API (and wiki edit Permissions please)

Post by peepsalot »

I'm trying to follow the wiki page here and nothing is going right:
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
".children" attribute does not exist. There is a ".children()" method though.
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
QSize doesn't accept a QRect parameter, just two ints, or another QSize. I think

Code: Select all

myWidget.resize(QtCore.QSize(300,100)) # sets size of the widget
does what is intended.
Why bother creating a label if you put no text in it?

Code: Select all

label = QtGui.QLabel("Hello World", myWidget) # creates a label
Doing this instead would at least give visual indication that it's working.

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.
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Help with PyQt API (and wiki edit Permissions please)

Post by wmayer »

Go ahead and fix documentation where needed. You have the rights now.
Post Reply