Adding a minimize button to a Qt dialog?

流过昼夜 提交于 2019-12-23 09:04:04

问题


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?


回答1:


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);



回答2:


Use the QDialog constructor's Qt::WindowFlags for minimize.

Qt::WindowMinimizeButtonHint




回答3:


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.



来源:https://stackoverflow.com/questions/1080876/adding-a-minimize-button-to-a-qt-dialog

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!