Results 1 to 6 of 6

Thread: New widgets after application begins

  1. #1
    Join Date
    May 2007
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default New widgets after application begins

    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?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: New widgets after application begins

    • Do you allocate those widgets on the heap (with keyword "new")?
    • Do you call show() on those dynamically added widgets?
    J-P Nurmi

  3. #3
    Join Date
    May 2007
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: New widgets after application begins

    Quote Originally Posted by jpn View Post
    • 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?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: New widgets after application begins

    Quote Originally Posted by petty View Post
    _Should_ one be able to add new widgets during the mainloop?
    Sure, why not? Can we see your code?

  5. #5
    Join Date
    May 2007
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: New widgets after application begins

    Quote Originally Posted by wysota View Post
    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

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: New widgets after application begins

    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:
    Qt Code:
    1. self.Form.show()
    To copy to clipboard, switch view to plain text mode 
    You should call show() on the button, not on the form, because the latter is already visible, so the method will return immediately.

Similar Threads

  1. dll + application
    By fpujol in forum Qt Programming
    Replies: 11
    Last Post: 15th April 2007, 18:37
  2. Performance in hiding/showing widgets
    By Paalrammer in forum Newbie
    Replies: 12
    Last Post: 14th February 2007, 18:57
  3. Replies: 3
    Last Post: 8th December 2006, 18:51
  4. Replies: 11
    Last Post: 7th July 2006, 13:09
  5. Creating Widgets
    By hylke in forum Qt Programming
    Replies: 2
    Last Post: 5th February 2006, 08:37

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.