user1824542
user1824542

Reputation: 225

Widget won't hide

I guess this silly question but why doesn't my widget hide after is shown?

void Dialog::on_tabWidget_selected(const QString &arg1){
    QWidget *w = new QWidget();
    if(ui->tabWidget->currentIndex() == 3){
             w -> move(1093,278);
             w -> setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
             w -> setFixedSize(206,206);
             w -> show();
     }else{
        w ->hide();
    }
}

Upvotes: 0

Views: 689

Answers (1)

Sylvain V
Sylvain V

Reputation: 194

The second time, it creats a new QWidget, so the hide does not affect the old widget if that's what you want to do. Maybe you should explain a little bit more what is the result expected ?

EDIT: if you want to display a popup when this tab is open, just use the widget's showEvent and hideEvent. Or you can remove the "widget *w = new widget();", add "QWidget *w;" to the *.h, and add "w = new QWidget();" to the constructor, and it should work.

Upvotes: 3

Related Questions