Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > RE: QWidget casts with PyQt?

Reply
Thread Tools

RE: QWidget casts with PyQt?

 
 
Michael Pyle
Guest
Posts: n/a
 
      02-20-2004
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


--mike

-----Original Message-----
From: Ewald R. de Wit [private.php?do=newpm&u=]
Sent: Friday, February 20, 2004 2:42 AM
To: python-
Subject: Re: QWidget casts with PyQt?


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.

--
-- Ewald

--
http://mail.python.org/mailman/listinfo/python-list

 
Reply With Quote
 
 
 
 
Jim Bublitz
Guest
Posts: n/a
 
      02-21-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>
> 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
 
Reply With Quote
 
 
 
 
Stefan Quandt
Guest
Posts: n/a
 
      02-23-2004
Jim Bublitz <> wrote in message news:<RpEZb.27969$ .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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
checking casts Dan Upton Java 4 12-01-2005 06:20 PM
Web casts in ASP.Net =?Utf-8?B?Q2hyaXMgRGF2b2xp?= ASP .Net 1 10-19-2005 09:45 PM
Needless casts? Joona I Palaste Java 15 04-25-2004 10:14 PM
QWidget casts with PyQt? Stefan Quandt Python 1 02-20-2004 10:42 AM
Re: = operator should automatically perform appropriate casts cgbusch Java 2 07-08-2003 03:58 PM



Advertisments