How to hide the dialog window close button?
-
wrote on 3 Mar 2011, 07:37 last edited by
I want a waiting Dialog, an how to create non button on dialog window?
Now, my methods is hook the close event. It's goes well, but it's confuse users.
-
wrote on 3 Mar 2011, 09:41 last edited by
Its the correct function, the usage is the following:
- "QWidget::setWindowFlags":http://doc.qt.nokia.com/latest/qwidget.html#windowFlags-prop
- "Qt::WindowsFlags":http://doc.qt.nokia.com/latest/qt.html#WindowType-enum
@
MyDialog::MyDialog(QWidget* pParent) :
QDialog(pParent, Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint )
{
}
@ -
wrote on 3 Mar 2011, 10:17 last edited by
I don't remember if you have any flag to dissable the close button, but in that scenario, you could apply the:
Qt::FramelessWindow
Flag in the initialization of the QDialog parent, and that will allow you to dismiss the NonClient Area (titlebar, the window borders), in that case you have to provide a way to close the window.Regards!
-
wrote on 3 Mar 2011, 10:27 last edited by
FramelessWindow removes the complete frame
Qt::CustomizeWindowHint says: i say what to display. If you don't set Qt::WindowSystemMenuHint or Qt::WindowCloseButtonHint, the close button should be away but you have a title bar, window frame etc.
-
wrote on 3 Mar 2011, 11:29 last edited by
I think this removes only the close button
@dialog->setWindowFlags( ( (dialog->windowFlags() | Qt::CustomizeWindowHint)
& ~Qt::WindowCloseButtonHint) );@ -
wrote on 3 Mar 2011, 11:46 last edited by
no it removes everything, also max and min button.
windows flags does not contain min/m ax hint by default, as they are only needed if Qt::CustomizeWindowHint is used. -
wrote on 3 Mar 2011, 12:43 last edited by
[quote author="Gerolf" date="1299145299"]Its the correct function, the usage is the following:
- "QWidget::setWindowFlags":http://doc.qt.nokia.com/latest/qwidget.html#windowFlags-prop
- "Qt::WindowsFlags":http://doc.qt.nokia.com/latest/qt.html#WindowType-enum
@
MyDialog::MyDialog(QWidget* pParent) :
QDialog(pParent, Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint )
{
}
@[/quote]Thanks, your methods is fantancy. But's a little flaw. the Min button and Max button not hint.
-
wrote on 3 Mar 2011, 13:16 last edited by
if you don't want m in/max button, remove them from the flas.
-
wrote on 3 Mar 2011, 16:16 last edited by
[quote author="Gerolf" date="1299158166"]if you don't want m in/max button, remove them from the flas.[/quote]
Haha, yes. It's fine. Thanks all.
-
wrote on 15 May 2020, 23:46 last edited by
@giesbert said in How to hide the dialog window close button?:
if you don't want m in/max button, remove them from the flas.
You mean like this?
: QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowTitleHint )
That does not work, the min/max buttons, i.e. the small arrows on the right hand side, are still there. I have tried various combinations of flags, but I cannot get rid of those arrows. I don't want to remove the top panel. -
@giesbert said in How to hide the dialog window close button?:
if you don't want m in/max button, remove them from the flas.
You mean like this?
: QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowTitleHint )
That does not work, the min/max buttons, i.e. the small arrows on the right hand side, are still there. I have tried various combinations of flags, but I cannot get rid of those arrows. I don't want to remove the top panel.wrote on 16 May 2020, 03:00 last edited byThis thread is 9 years old :)
Check out the QT Window Flag example:
https://doc.qt.io/qt-5/qtwidgets-widgets-windowflags-example.html