PDA

View Full Version : QFile Dialog doesn't display on the Top



Veera
27th September 2017, 13:56
I have several Dialogs with window Flags as WindowStaysonTopHint. When I open QFileDialog it displays at the bottom of these dialogs. How to set window Flag for QFileDialog. I use the following code to display the dialog at the top but it doesn't work.

> QFileDialog *dialog=new QFileDialog();
>
> dialog->setWindowModality(Qt::ApplicationModal);
>
> dialog->setModal(true);
> dialog->setWindowFlags(Qt::WindowStaysonTopHint);
> dialog->getExisitngDirectory(this,tr("Directory"),"\home",QFileDialog::ShowDirsOnly);

Simply, I am looking for a non static get existing directory function.

Gokulnathvc
27th September 2017, 14:20
Try to use dialog->exec() rather than dialog->show()

Veera
27th September 2017, 16:18
I am using dialog->exec() but it doesn't work. there is no parent for the QFileDialog that I am using.

d_stranz
27th September 2017, 16:41
I have several Dialogs with window Flags as WindowStaysonTopHint.

You can't have it both ways. You have told the windowing system that these dialogs must stay on top of other windows, so it will keep them on top. You can't now say, "Oh, but I want them on top except when I post my file dialog. Put that on top instead for a short time."

You can try using QWidget::raise() but this may not work for top-level widgets (i.e. parentless).

Veera
27th September 2017, 16:54
When I use the same code for a dialog with parent as mainwindow it displays on top of all other toplevelwidgets. I want to implement same with the dialog with no parent.

d_stranz
27th September 2017, 20:37
*Sigh* Re-read my previous answer.