Results 1 to 10 of 10

Thread: How to add widgets when program is already running?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2009
    Posts
    46
    Thanks
    4
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to add widgets when program is already running?

    Yes, button->show() solves my problem, thanks.

  2. #2
    Join Date
    Feb 2008
    Posts
    98
    Thanks
    2
    Thanked 24 Times in 24 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to add widgets when program is already running?

    If you want to replace the old buttons with new ones, remember to delete any previous buttons you are not using anymore. Otherwise you will have memory leaks (the buttons will take memory that is allocated but can't be accesed and is useless). The best solution would be to try to reuse the buttons or keep a list of pointers to the buttons and use qDeleteAll(). But if all the buttons are children of your main widget and you don't use any other buttons in it, you may use this:

    Qt Code:
    1. foreach(QObject* child, children()) {
    2. if(child->metaObject()->className() == "QPushButton")
    3. child->deleteLater();
    4. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. How to check if a program is running?
    By raphaelf in forum Newbie
    Replies: 16
    Last Post: 30th April 2010, 15:59
  2. Help me how to know the program is running
    By vql in forum Qt Programming
    Replies: 1
    Last Post: 21st March 2008, 12:43
  3. Detect platform where my QT4 program is running on
    By the_bis in forum Qt Programming
    Replies: 1
    Last Post: 14th September 2007, 12:01
  4. QT MySQL
    By sabeeshcs in forum Newbie
    Replies: 6
    Last Post: 12th January 2007, 04:19
  5. Replies: 1
    Last Post: 17th May 2006, 00:23

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.