maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Remove widget from a layout (https://talk.maemo.org/showthread.php?t=63534)

Lullen 2010-10-08 13:30

Remove widget from a layout
 
How do I remove a widget from a layout?

Code:

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    startGui = new StartScreenGUI();
    ui->verticalLayout->insertWidget(0,startGui);
}


void MainWindow::switchToStart()
{
    deleteGuis();

    startGui = new StartScreenGUI();
    ui->verticalLayout->insertWidget(0,startGui);
}
void MainWindow::deleteGuis()
{
    ui->verticalLayout->removeWidget(startGui);

    ui->verticalLayout->removeWidget(schemeGui);

    ui->verticalLayout->removeWidget(settingsGui);

    ui->verticalLayout->removeWidget(listGui);

    ui->verticalLayout->removeWidget(historyGui);
   
}

What have I done wrong here? What happens is that it just put the new widget on top on the old one. I have tried the update() function but it does not seem to do anything in this case. It works if I delete the widget but as I do not know what widget that is in the layout at the moment I have no idea how to destroy the widget as I can not delete widgets that is already deleted(program freezes)

uvatbc 2010-10-08 15:37

Re: Remove widget from a layout
 
Removing the widget from the layout is not enough. Hide it.


All times are GMT. The time now is 09:41.

vBulletin® Version 3.8.8