QWidget casts with PyQt?
jbublitzno at spamnwinternet.com
Sat Feb 21 09:12:11 CET 2004
Michael Pyle wrote:
> Just use the reference you get back as a QButtonGroup object.
> The following code works fine for me:
> from qt import *
> app = QApplication()
> box = QToolBox()
> grp = QButtonGroup()
> box.addItem( grp, 'button group' )
> item = box.item( 0 )
> print item
> print item.isRadioButtonExclusive()
> This outputs:
> <__main__.qt.QButtonGroup object at 0x00804360>
> Stefan Quandt wrote:
>> I want to access widgets from a Qt container widget e.g.
>> item = ToolBox.item( 0 )
>> I know that the item is a QButtonGroup.
>> The Qt-Library returns a QWidget pointer.
>> So what I get is a Python QWidget wrapper object.
> This is quite a general problem for which I would like to know
> a solution too.
As a general solution, methods and functions (including factory
functions) which return a pointer cast down to a QWidget or
QObject base type will return an object of the original type in
Python with PyQt or PyKDE (as shown above). Same for QEvent
If they don't, you should report a bug on the PyKDE mailing list.
More information about the Python-list