Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a dialog window always on the front at my application level

How can I make a Qt dialog window always on top at my application level?

I want to make a dialog window always on the front but remember always on the front at my application level, even if I click on an empty place, I want to it stay on the front of my application only.

I have tried to use setWindowFlags(Qt::WindowStaysOnTopHint), but this makes the dialog window always on the top at the desktop level, but I want it to be on top at the my application level only.

How can I do that?

like image 482
Lion King Avatar asked Oct 11 '14 14:10

Lion King


2 Answers

You can achieve this by giving the dialogs a parent. A child dialog always stays on top of its parent window.

like image 174
Silicomancer Avatar answered Nov 18 '22 09:11

Silicomancer


If you can't send parent to your dialog_window (based on code conditional) Like me, use flags.

Dialog_dlg::Dialog_dlg(QWidget *parent)
    : QDialog(parent), ui(new Ui::Dialog_dlg)
{
    ui->setupUi(this);
    setFixedSize(width(), height()); //for no maximaize
    setWindowFlag(Qt::WindowStaysOnTopHint);
}

I used this and good to me. See other flags, test them, and choose.

like image 4
Mahdi Avatar answered Nov 18 '22 08:11

Mahdi