[PyKDE] autoAdding buttons to a grid
Phil Thompson
phil at riverbankcomputing.co.uk
Tue May 17 17:27:24 BST 2005
>> > bgMainLayout.activate()
>> >
>> > But the items never showup in my buttongroup.
>>
>> Neither you or the QButtonGroup are keeping a reference to the
>> QPushButton
>> so it is getting garbage collected immediately. I need to check the Qt
>> source to see if the QButtonGroup should keep a reference (in which case
>> it's a PyQt bug) or you need to do it explicitly.
>
> I thought about that but the docs say that in autoinsert mode the
> parent of the items inserted is changed to ownership by the
> buttongroup. Or at least thats how I read it. So I figured I didn't
> need it.
>
> I need a reference to those items anyway for easy access. Guess just
> blind luck I didn't add them to a list to start with.
>
> I'll stick them in a list and see how it goes.
>
> Thanks for the help. I'm glad I asked bc that would have probally
> taken me a long time to figure out on my own with trial and error.
You may still have problems as the button dtors may be called twice. The
fix (if you are happy to rebuild PyQt) is to add /Transfer/ to the
argument of the QButtonGroup::insert() method.
Phil
More information about the PyQt
mailing list