[英]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. 我已经使用Qt Creator创建了一个基于
QDialog
的应用程序,除了对话框没有最小化按钮之外,其他都很好。 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.
您可以告诉窗口管理器如何使用Window Manager提示处理对话框。 This is done using the windowFlags property of your widget.
这是使用窗口小部件的windowFlags属性完成的。 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 您还可以使用setWindowState尝试使用以下内容
QWidget->setWindowState(Qt::WindowMinimized);
This way you cand add a button or an event to minimize the Dialog. 通过这种方式,您可以添加按钮或事件以最小化对话框。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.