Qt隐藏最小化,最大化和关闭按钮
答
设置窗口标志Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint
。注意,在某些平台上,它的行为以不同的方式。例如,在Mac OS X上它禁用,(不隐藏)关闭/最小化/最大化按钮
答
这可以通过使用在QEvent的一个eventFilter ::关闭事件从主窗口
bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
if (event->type() == QEvent::Close) {
event->ignore();
doWhateverYouNeedToDoBeforeClosingTheApplication();
return true;
}
return QMainWindow::eventFilter(obj, event);
}
void MainWindow::doWhateverYouNeedToDoBeforeClosingTheApplication() {
// Do here what ever you need to do
// ...
// ...
// and finally quit
qApp->quit();
}
答
如果你被achived使用的是Qt QML然后,除去最小化,最大化和关闭按钮,在设置窗口功能的无框窗标志的main.qml文件,如下图所示:
flags: Qt.FramelessWindowHint
答
标志:Qt.Dialog | Qt.WindowCancelButtonHint | Qt.WindowCloseButtonHint
这也适用于一个窗口项
标志:Qt.Window | Qt.WindowTitleHint
+0
基于这些名字,我不认为这些是正确的标志......这就是为什么OP有问题找到它吗? – Taegost 2017-11-28 21:42:43
难道你提到为什么你需要做的是什么? – 2010-07-09 09:29:03
我不想让用户在角落按x关闭我的应用程序。我希望他在退出手术之前做一些过程。 – ufukgun 2010-07-12 06:54:03