Results 1 to 4 of 4

Thread: GUI re-populate

  1. #1
    Join Date
    Oct 2015
    Posts
    45
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default GUI re-populate

    Did some searching, but, as usual my search terms are lacking...

    I have a mainwindow (and appropriate layouts, etc.) with a tabwidget on it.

    When my code loads a "project", the project may need n tabs.

    When the program starts it reads a project and displays the appropriate number of tabs, lets say 2 tabs. Each tab then gets a lot of controls, labels, etc.

    Then the user may select FIle > Open and select a new project.

    During the loading of the new project, I want to throw away the old tabs and repopulate the widget with a new set of n tabs.

    I'm guessing there is a proper term to describe this that would make this description less wordy (and is probably what I should use as a search term...).

    The question is how to or what is the process of clearing out the old tabs in the widget and repopulating with new tabs.

    Mac

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    507
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: GUI re-populate

    Hi, QTabwidget::clear() removes all tabs. You might want to delete them, too.

    Ginsengelf

  3. #3
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: GUI re-populate

    Quote Originally Posted by Ginsengelf View Post
    Hi, QTabwidget::clear() removes all tabs. You might want to delete them, too.

    Ginsengelf
    It will cause memory leak.

    Quote Originally Posted by Qt Documentaion
    void QTabWidget::clear()

    Removes all the pages, but does not delete them. Calling this function is equivalent to calling removeTab() until the tab widget is empty.
    Why not just remove the tabs and delete them, may not be huge number of them.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  4. #4
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    507
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: GUI re-populate

    Quote Originally Posted by Ginsengelf View Post
    You might want to delete them, too.
    Quote Originally Posted by Santosh Reddy View Post
    It will cause memory leak.
    That's what I wanted to say.

    Ginsengelf

Similar Threads

  1. Populate QTreeView from database
    By yagabey in forum Qt Programming
    Replies: 15
    Last Post: 26th March 2015, 02:10
  2. treelist didnt populate
    By ditsikts in forum Newbie
    Replies: 0
    Last Post: 2nd November 2011, 14:11
  3. Populate QTableWidget
    By ruben.rodrigues in forum Qt Programming
    Replies: 2
    Last Post: 3rd May 2011, 14:21
  4. how to populate data in QTableWidget
    By gauravg in forum Qt-based Software
    Replies: 1
    Last Post: 25th March 2011, 12:50
  5. PyQt Populate a QTableWidget
    By n3wcr4zy in forum Newbie
    Replies: 0
    Last Post: 2nd March 2011, 08:20

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.