简体   繁体   中英

Adding a minimize button to a Qt dialog?

I have created a QDialog based app using Qt Creator and all is well other than the dialog has no minimize button. How can I add one? Is there a property in the designer that I can set?

You can't add the minimize button yourself as it is handled by the window manager. You can tell the window manager how your dialog should be handled using Window Manager hints. This is done using the windowFlags property of your widget. There's also an example demonstrating this.

setWindowFlags(windowFlags() | Qt::WindowMinimizeButtonHint);

使用QDialog构造函数Qt :: WindowFlags进行最小化。

Qt::WindowMinimizeButtonHint

You can also try to use the following, by using setWindowState

QWidget->setWindowState(Qt::WindowMinimized);

This way you cand add a button or an event to minimize the Dialog.

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