[PyKDE] autoAdding buttons to a grid

Richard Smith smithbone at gmail.com
Wed May 18 07:19:18 BST 2005


> 
> However I get exaclty the same results.  Nothing.
> 

Ok.. I worked with this more tonight and I don't think you can do what
I want to do with stock Qt widgets.  The core problem seems to be that
I'm *not* trying to do this in the __init__ method but rather from a
slot thats gets called in response to a button press.

If I move my code up into my __init__ method for the window class then
it all works fine but the same stuff does not work when run from my
slot.

Reading the QT docs seems to suggest that once a layout has been
rendered then its not very easy to change.

Basically I want to create an app with one window.  On this window
there is an area where buttons appear and dissapear depending on what
the user does.  I don't want to open a new window.

I'm designing this app to be used via a touchscreen and eventually the
app will run fullscreen perhaps without a window manager or maybe
eventually directly on the framebuffer via QT Embeded.  So one window
with lots of big buttons that come and go.

But so far I don't see how I to delete buttons once they have been
added.  I thought a buttongroup would make this easy but perhaps not.

The closest thing I've found in the docs to removing a widget is
reparent() but the docs say:

"Warning: It is extremely unlikely that you will ever need this
function. If you have a widget that changes its content dynamically,
it is far easier to use QWidgetStack or QWizard."

But QWidgetStack and QWizard aren't what I'm looking for. 
QWidgetStack only displays one widget at a time and QWizard creates a
whole new dialog.

I just want A simple widget or container that I can change its
contents dynamically.  I'd be happy with just being able to delete the
entire QButtonGroup from the from and recreate a new one with my
contents.  But It's not obvious how to do that.

I've dynamically created a QButtonGroup with buttons and stuck it into
a list but even after the list goes out of scope the buttogroup and
buttons persist on the screen.

Is there is a way to delete buttons from a ButtonGroup or delete
things off of a form after its been rendered?

-- 
Richard A. Smith




More information about the PyQt mailing list