PDA

View Full Version : New widgets after application begins



petty
7th May 2007, 21:53
I would like an application that draws new widgets according to user input (say, prompt a user where to put a button) but new widgets created after the QApplication runs are not shown.

Is there a way to do this that I'm missing? Is it possible to force widgets to be added, or can I add all the widgets and change their location and visibility? Or should I use a Qgraphicsscene to draw everything, and then try to emulate the functionality of the widgets I want to display?

jpn
7th May 2007, 22:23
Do you allocate those widgets on the heap (with keyword "new")?
Do you call show() on those dynamically added widgets?

petty
7th May 2007, 22:49
Do you allocate those widgets on the heap (with keyword "new")?
Do you call show() on those dynamically added widgets?


I'm actually using the python bindings for Qt, but the 'new' widgets are being created the same way that all the 'original' widgets that are created are.

_Should_ one be able to add new widgets during the mainloop?

wysota
8th May 2007, 02:23
_Should_ one be able to add new widgets during the mainloop?

Sure, why not? Can we see your code?

petty
8th May 2007, 02:56
Sure, why not? Can we see your code?

Sure, here:
http://putnote.net/203
Its just a quick thing I jimmied up to make sure I hadn't missed anything, but what it does is, calls a function to set up the ui, then another to position a button at 0,0.
It sets up a signal on that button to call the previous button-positioning function and put a new button at 10,10.
As far as I can see, it is getting to put the button down, but it's never seen to be visible.

Thanks,
Petty

wysota
8th May 2007, 13:10
Next time please paste the code here on the forum instead of using external sites.
In your bClick() after you add a button you do:

self.Form.show()
You should call show() on the button, not on the form, because the latter is already visible, so the method will return immediately.