Qt官方示例-窗口標誌
- 2019 年 11 月 27 日
- 筆記
窗口標誌示例展示了如何使用Qt中可用的窗口標誌類型來指定各窗口系統屬性。

根據示例整理出來的各窗口標誌作用一覽表如下:
- 只能設置一個的窗口標誌對照表
窗口的默認屬性
- 可以設置多個的窗口標誌對照表

- 部分程式碼(更新窗口標誌)
void ControllerWindow::updatePreview() { Qt::WindowFlags flags = 0; if (windowRadioButton->isChecked()) { flags = Qt::Window; } else if (dialogRadioButton->isChecked()) { flags = Qt::Dialog; } else if (sheetRadioButton->isChecked()) { flags = Qt::Sheet; } else if (drawerRadioButton->isChecked()) { flags = Qt::Drawer; } else if (popupRadioButton->isChecked()) { flags = Qt::Popup; } else if (toolRadioButton->isChecked()) { flags = Qt::Tool; } else if (toolTipRadioButton->isChecked()) { flags = Qt::ToolTip; } else if (splashScreenRadioButton->isChecked()) { flags = Qt::SplashScreen; } if (msWindowsFixedSizeDialogCheckBox->isChecked()) flags |= Qt::MSWindowsFixedSizeDialogHint; if (x11BypassWindowManagerCheckBox->isChecked()) flags |= Qt::X11BypassWindowManagerHint; if (framelessWindowCheckBox->isChecked()) flags |= Qt::FramelessWindowHint; if (windowNoShadowCheckBox->isChecked()) flags |= Qt::NoDropShadowWindowHint; if (windowTitleCheckBox->isChecked()) flags |= Qt::WindowTitleHint; if (windowSystemMenuCheckBox->isChecked()) flags |= Qt::WindowSystemMenuHint; if (windowMinimizeButtonCheckBox->isChecked()) flags |= Qt::WindowMinimizeButtonHint; if (windowMaximizeButtonCheckBox->isChecked()) flags |= Qt::WindowMaximizeButtonHint; if (windowCloseButtonCheckBox->isChecked()) flags |= Qt::WindowCloseButtonHint; if (windowContextHelpButtonCheckBox->isChecked()) flags |= Qt::WindowContextHelpButtonHint; if (windowShadeButtonCheckBox->isChecked()) flags |= Qt::WindowShadeButtonHint; if (windowStaysOnTopCheckBox->isChecked()) flags |= Qt::WindowStaysOnTopHint; if (windowStaysOnBottomCheckBox->isChecked()) flags |= Qt::WindowStaysOnBottomHint; if (customizeWindowHintCheckBox->isChecked()) flags |= Qt::CustomizeWindowHint; previewWindow->setWindowFlags(flags); ... }關於更多
- 在QtCreator軟體可以找到:

- 在以下Qt安裝目錄找到:
C:Qt{你的Qt版本}Examples{你的Qt版本}widgetswidgetswindowflags- 相關鏈接
https://doc.qt.io/qt-5/qtwidgets-widgets-windowflags-example.html
