简体   繁体   中英

How to QDialog raise() function is not working?

From my QMainwindow I am opening a second QDialog window when a pushbutton is pressed.This is my code

  newFile = new Dialog(); if(fStatus == 0) { newFile.show(); fStatus = 1; } else if(fStatus == 1) { newFile.raise(); } 

What I am trying to do is if the QDialog window is already open and the push button is pressed again I want my QDialog window to move to front.

I have tried same with Qwidget form it is working but Qdialog raise(); is not working,but in case of Qwidget I am not able not capture the Qwidget destroyed signal on closing of the widow properly.

I didn't tested it but from what I read I found this :

yourQWidget->show();
yourQWidget->activateWindow();
yourQWidget->raise();

How to Bring the Widget Bring to front in QT?

QDialog *yourQDialog = new ...
yourQDialog->setWindowFlags(yourQDialog->windowFlags() | Qt::WindowStaysOnTopHint);
yourQDialog->show();

Bring QDialog to front

Also loook at this question: Bring window to front -> raise(),show(),activateWindow() don't work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM