Force dialogs to float; like QInputDialog
-
Pretext: I use a tiling window manager that has the ability to make certain windows float (in my case, sway).
Whenever I use Qt's built-in dialogs like QInputDialog, the dialogs float as such (using
QInputDialog::getText):
However, I am looking to getting
QDialogs I subclass to also show like this, but all of them get tiled along with the rest of my windows.I looked at the source code for the
getTextmethod:QString QInputDialog::getText(QWidget *parent, const QString &title, const QString &label, QLineEdit::EchoMode mode, const QString &text, bool *ok, Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints) { QAutoPointer<QInputDialog> dialog(new QInputDialog(parent, flags)); dialog->setWindowTitle(title); dialog->setLabelText(label); dialog->setTextValue(text); dialog->setTextEchoMode(mode); dialog->setInputMethodHints(inputMethodHints); const int ret = dialog->exec(); // ... }This looks suspiciously like it does absolutely nothing to make it appear as a popup like that, except maybe for the use of
exec. I tried usingexecas well (which I wouldn't have wanted either way due to its blocking nature), but this did NOT work.I also tried various window flags;
Qt::WindowStaysOnTopHint,Qt::Popup,Qt::Tool, none achieved anything. TriedsetModal(true), didn't work.What does the
QInputDialogdo to achieve this that I don't understand? Or is this some weird quirk of i3/sway? -
@ChrisW67 The QInputDialog's parent widget is the main window class. Looks like I forgot to set the parent of the other dialogs... would that achieve the behavior I'm looking for?
-
Pretext: I use a tiling window manager that has the ability to make certain windows float (in my case, sway).
Whenever I use Qt's built-in dialogs like QInputDialog, the dialogs float as such (using
QInputDialog::getText):
However, I am looking to getting
QDialogs I subclass to also show like this, but all of them get tiled along with the rest of my windows.I looked at the source code for the
getTextmethod:QString QInputDialog::getText(QWidget *parent, const QString &title, const QString &label, QLineEdit::EchoMode mode, const QString &text, bool *ok, Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints) { QAutoPointer<QInputDialog> dialog(new QInputDialog(parent, flags)); dialog->setWindowTitle(title); dialog->setLabelText(label); dialog->setTextValue(text); dialog->setTextEchoMode(mode); dialog->setInputMethodHints(inputMethodHints); const int ret = dialog->exec(); // ... }This looks suspiciously like it does absolutely nothing to make it appear as a popup like that, except maybe for the use of
exec. I tried usingexecas well (which I wouldn't have wanted either way due to its blocking nature), but this did NOT work.I also tried various window flags;
Qt::WindowStaysOnTopHint,Qt::Popup,Qt::Tool, none achieved anything. TriedsetModal(true), didn't work.What does the
QInputDialogdo to achieve this that I don't understand? Or is this some weird quirk of i3/sway? -
@ChrisW67 The QInputDialog's parent widget is the main window class. Looks like I forgot to set the parent of the other dialogs... would that achieve the behavior I'm looking for?
-
@swurl The window manager may treat a top-level modal dialog, i.e. unparented and opened with exec(), to one that has a parent. It may also treat an application modal dialog differently to a window-modal one.
-
S swurl has marked this topic as solved on