PDA

View Full Version : GUI re-populate



drmacro
22nd June 2017, 15:56
Did some searching, but, as usual my search terms are lacking...:p

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

Ginsengelf
23rd June 2017, 10:08
Hi, QTabwidget::clear() removes all tabs. You might want to delete them, too.

Ginsengelf

Santosh Reddy
23rd June 2017, 12:31
Hi, QTabwidget::clear() removes all tabs. You might want to delete them, too.

Ginsengelf

It will cause memory leak.


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.

Ginsengelf
26th June 2017, 08:04
You might want to delete them, too.

It will cause memory leak.
That's what I wanted to say.

Ginsengelf