QWidget casts with PyQt?

Stefan Quandt squan at web.de
Mon Feb 23 02:55:20 EST 2004


Jim Bublitz <jbublitzno at spamnwinternet.com> wrote in message news:<RpEZb.27969$U77.3101698165 at twister2.starband.net>...
> 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>
> > True
>  
> > 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
> based objects.
> 
> If they don't, you should report a bug on the PyKDE mailing list.
> 
> Jim
Oh, that's great.

Thanks for clarifying.
  Stefan



More information about the Python-list mailing list