Qt::WindowFlags
文章目录
- Qt::WindowFlags
- 摘要
- 窗口&部件
- Qt::WindowFlags&WindowType
- 窗口类型
- 窗口提示
关键字:
Qt
、
Qt::WindowFlags
、
Qt::WindowType
、
关键字4
、
关键字5
摘要
今天在公司解决自己的Bugs的时候,发现一个以前可以用的功能在自己的新代码里面不可用了,所以就得解决一下自己写得BUG,就是有一个功能时需要把里面的个控件 浮动出来显示,如果没有之前的参考代码,那我就直接用Tool 窗口显示了,但是呢,上一版本版本代码中竟然是通过给 控件设置空的父类来解决,也就是调用了QWidget::setParent(nullptr);虽然感觉怪怪,但是本着能跑就不要动的原则,还是维持了原来的代码,直到这个法子在新的功能中不好使用,才不得重新学一下相关的知识。
窗口&部件
窗口标识由两部分组成,分别是窗口类型和窗口提示hint,一个窗口只有一个窗口类型。窗口提示定义了窗口的外观,可以有多个提示,窗口提示进行按位取或即可
要说清楚Qt::WindowFlags枚举类型就必须清楚两个概念:窗口和部件
**窗口:**相对独立,有子窗口和父窗口之分,主要特点就是窗口有完整的边框。
**部件:**必须依赖父窗口而存在,依赖性较强,出现在父窗体的界面内部。
Qt::WindowFlags&WindowType
窗口类型
此枚举类型用于指定小部件的各种窗口系统属性。它们相当不寻常,但在少数情况下是必要的。其中一些标志取决于基础窗口管理器是否支持它们。
Constant | Value | Description | 我的翻译 |
---|---|---|---|
Qt::Widget | 0x00000000 | This is the default type for QWidget. Widgets of this type are child widgets if they have a parent, and independent windows if they have no parent. See also Qt::Window and Qt::SubWindow. | 这是 的缺省类型。如果这种类型的小部件有父级,则为子级,如果没有父级,则为独立窗口。参见 Qt::Window 和 Qt::SubWindow。 |
Qt::Window | 0x00000001 | Indicates that the widget is a window, usually with a window system frame and a title bar, irrespective of whether the widget has a parent or not. Note that it is not possible to unset this flag if the widget does not have a parent. | 指示小组件是一个窗口,通常具有窗口系统框架和标题栏,而不管小组件是否具有父级。请注意,如果小组件没有父级,则无法取消设置此标志。 |
Qt::Dialog | 0x00000002 Window | Indicates that the widget is a window that should be decorated as a dialog (i.e., typically no maximize or minimize buttons in the title bar). This is the default type for QDialog. If you want to use it as a modal dialog, it should be launched from another window, or have a parent and used with the QWidget::windowModality property. If you make it modal, the dialog will prevent other top-level windows in the application from getting any input. We refer to a top-level window that has a parent as a secondary window. | 指示小组件是一个窗口,应将其修饰为对话框(即,标题栏中通常没有最大化或最小化按钮)。这是 的缺省类型。如果要将其用作模式对话框,则应从另一个窗口启动它,或者具有父级并与属性一起使用。如果将其设置为模式,则该对话框将阻止应用程序中的其他顶级窗口获取任何输入。我们将具有父窗口的顶级窗口称为辅助窗口。 |
Qt::Sheet | 0x00000004 Window | Indicates that the window is a sheet on macOS. Since using a sheet implies window modality, the recommended way is to use QWidget::setWindowModality(), or QDialog::open(), instead. | 指示窗口是 macOS 上的工作表。由于使用工作表意味着窗口形式,因此推荐的方法是使用 () 或 () 代替。 |
Qt::Drawer | Sheet Dialog | Indicates that the widget is a drawer on macOS. This feature is obsolete. Setting the flag has no effect. | 指示小组件是 macOS 上的抽屉。此功能已过时。设置标志不起作用。 |
Qt::Popup | 0x00000008 Window | Indicates that the widget is a pop-up top-level window, i.e. that it is modal, but has a window system frame appropriate for pop-up menus. | 指示小组件是弹出式顶级窗口,即它是模式窗口,但具有适用于弹出菜单的窗口系统框架。 |
Qt::Tool | Popup Dialog | Indicates that the widget is a tool window. A tool window is often a small window with a smaller than usual title bar and decoration, typically used for collections of tool buttons. If there is a parent, the tool window will always be kept on top of it. If there isn’t a parent, you may consider using Qt::WindowStaysOnTopHint as well. If the window system supports it, a tool window can be decorated with a somewhat lighter frame. It can also be combined with Qt::FramelessWindowHint. On macOS, tool windows correspond to the NSPanel class of windows. This means that the window lives on a level above normal windows making it impossible to put a normal window on top of it. By default, tool windows will disappear when the application is inactive. This can be controlled by the Qt::WA_MacAlwaysShowToolWindow attribute. | 指示小组件是工具窗口。工具窗口通常是一个小窗口,其标题栏和装饰比通常的要小,通常用于工具按钮的集合。如果存在父窗口,则工具窗口将始终保留在其顶部。如果没有父级,您也可以考虑使用 Qt::WindowStaysOnTopHint。如果窗口系统支持它,则可以用较轻的框架来装饰工具窗口。它也可以与Qt::FramelessWindowHint结合使用。在 macOS 上,工具窗口对应于窗口类。这意味着窗户位于普通窗户上方的水平上,因此不可能在其上放置普通窗户。默认情况下,当应用程序处于非活动状态时,工具窗口将消失。这可以通过属性来控制。 |
Qt::ToolTip | Popup Sheet | Indicates that the widget is a tooltip. This is used internally to implement tooltips. | 指示小组件是工具提示。这在内部用于实现 。 |
Qt::SplashScreen | ToolTip Dialog | Indicates that the window is a splash screen. This is the default type for QSplashScreen. | 指示窗口是初始屏幕。这是 的缺省类型。 |
Qt::Desktop | 0x00000010 Window | Indicates that this widget is the desktop. This is the type for QDesktopWidget. | 指示此小组件是桌面。这是 QDesktopWidget 的类型。 |
Qt::SubWindow | 0x00000012 | Indicates that this widget is a sub-window, such as a QMdiSubWindow widget. | 指示此小组件是子窗口,例如小组件。 |
Qt::ForeignWindow | 0x00000020 Window | Indicates that this window object is a handle representing a native platform window created by another process or by manually using native code. | 指示此窗口对象是一个句柄,表示由另一个进程或使用本机代码手动创建的本机平台窗口。 |
Qt::CoverWindow | 0x00000040 Window | Indicates that the window represents a cover window, which is shown when the application is minimized on some platforms. | 指示窗口表示一个覆盖窗口,当应用程序在某些平台上最小化时显示。 |
Constant | Value | Description | 我的翻译 |
---|---|---|---|
Qt::MSWindowsFixedSizeDialogHint | 0x00000100 | Gives the window a thin dialog border on Windows. This style is traditionally used for fixed-size dialogs. | 在 Windows 上为窗口提供细对话框边框。此样式传统上用于固定大小的对话框 |
Note: The use of this flag is not recommended in multi-monitor environments. This is because the system will enforce that the window maintains its native size when moving it across screens. This is particularly undesirable when using monitors with different resolutions.
注意:不建议在多显示器环境中使用此标志。这是因为在跨屏幕移动窗口时,系统将强制窗口保持其本机大小。当使用具有不同分辨率的显示器时,这尤其不可取。
Constant | Value | Description | 我的翻译 |
---|---|---|---|
Qt::MSWindowsOwnDC | 0x00000200 | Gives the window its own display context on Windows. | 在 Windows 上为窗口提供自己的显示上下文。 |
Qt::BypassWindowManagerHint | 0x00000400 | This flag can be used to indicate to the platform plugin that “all” window manager protocols should be disabled. This flag will behave different depending on what operating system the application is running on and what window manager is running. The flag can be used to get a native window with no configuration set. | 此标志可用于向平台插件指示应禁用“所有”窗口管理器协议。此标志的行为将有所不同,具体取决于应用程序运行的操作系统和运行的窗口管理器。该标志可用于获取未设置配置的本机窗口。 |
Qt::X11BypassWindowManagerHint | BypassWindowManagerHint | Bypass the window manager completely. This results in a borderless window that is not managed at all (i.e., no keyboard input unless you call QWidget::activateWindow() manually). | 完全绕过窗口管理器。这会导致一个完全不受管理的无边框窗口(即,除非您手动调用 (),否则没有键盘输入)。 |
Qt::FramelessWindowHint | 0x00000800 | Produces a borderless window. The user cannot move or resize a borderless window via the window system. On X11, the result of the flag is dependent on the window manager and its ability to understand Motif and/or NETWM hints. Most existing modern window managers can handle this. | 生成无边框窗口。用户无法通过窗口系统移动无边框窗口或调整其大小。在 X11 上,标志的结果取决于窗口管理器及其理解 Motif 和/或 NETWM 提示的能力。大多数现有的现代窗口管理器都可以处理这个问题。 |
Qt::NoDropShadowWindowHint | 0x40000000 | Disables window drop shadow on supporting platforms. | 在支持平台上禁用窗口投影。 |
窗口提示
Constant | Value | Description | 我的翻译 |
---|---|---|---|
Qt::CustomizeWindowHint | 0x02000000 | Turns off the default window title hints. | 关闭默认窗口标题提示 |
Qt::WindowTitleHint | 0x00001000 | Gives the window a title bar. | 为窗口提供标题栏 |
Qt::WindowSystemMenuHint | 0x00002000 | Adds a window system menu, and possibly a close button (for example on Mac). If you need to hide or show a close button, it is more portable to use WindowCloseButtonHint . | 添加窗口系统菜单,可能还有一个关闭按钮(例如在 Mac 上)。如果需要隐藏或显示关闭按钮,则使用 WindowCloseButtonHint 起来更便携。 |
Qt::WindowMinimizeButtonHint | 0x00004000 | Adds a minimize button. On some platforms this implies Qt::WindowSystemMenuHint for it to work. | 添加最小化按钮。在某些平台上,这意味着Qt::WindowSystemMenuHint才能工作。 |
Qt::WindowMaximizeButtonHint | 0x00008000 | Adds a maximize button. On some platforms this implies Qt::WindowSystemMenuHint for it to work. | 添加最大化按钮。在某些平台上,这意味着Qt::WindowSystemMenuHint才能工作。 |
Qt::WindowMinMaxButtonsHint | WindowMinimizeButtonHint WindowMaximizeButtonHint | Adds a minimize and a maximize button. On some platforms this implies Qt::WindowSystemMenuHint for it to work. | 添加最小化和最大化按钮。在某些平台上,这意味着Qt::WindowSystemMenuHint才能工作。 |
Qt::WindowCloseButtonHint | 0x08000000 | Adds a close button. On some platforms this implies Qt::WindowSystemMenuHint for it to work. | 添加关闭按钮。在某些平台上,这意味着Qt::WindowSystemMenuHint才能工作。 |
Qt::WindowContextHelpButtonHint | 0x00010000 | Adds a context help button to dialogs. On some platforms this implies Qt::WindowSystemMenuHint for it to work. | 向对话框添加上下文帮助按钮。在某些平台上,这意味着Qt::WindowSystemMenuHint才能工作。 |
Qt::MacWindowToolBarButtonHint | 0x10000000 | On macOS adds a tool bar button (i.e., the oblong button that is on the top right of windows that have toolbars). | 在 macOS 上,添加一个工具栏按钮(即具有工具栏的窗口右上角的长方形按钮)。 |
Qt::WindowFullscreenButtonHint | 0x80000000 | On macOS adds a fullscreen button. | 在 macOS 上添加一个全屏按钮。 |
Qt::BypassGraphicsProxyWidget | 0x20000000 | Prevents the window and its children from automatically embedding themselves into a QGraphicsProxyWidget if the parent widget is already embedded. You can set this flag if you want your widget to always be a toplevel widget on the desktop, regardless of whether the parent widget is embedded in a scene or not. | 如果父窗口小部件已嵌入,则阻止窗口及其子窗口自动将自己嵌入到中。如果您希望微件始终是桌面上的顶级微件,则可以设置此标志,而不管父微件是否嵌入到场景中。 |
Qt::WindowShadeButtonHint | 0x00020000 | Adds a shade button in place of the minimize button if the underlying window manager supports it. | 添加一个阴影按钮来代替最小化按钮(如果基础窗口管理器支持)。 |
Qt::WindowStaysOnTopHint | 0x00040000 | Informs the window system that the window should stay on top of all other windows. Note that on some window managers on X11 you also have to pass Qt::X11BypassWindowManagerHint for this flag to work correctly. | 通知窗口系统该窗口应位于所有其他窗口的顶部。请注意,在 X11 上的某些窗口管理器上,您还必须传递 Qt::X11BypassWindowManagerHint 才能使此标志正常工作。 |
Qt::WindowStaysOnBottomHint | 0x04000000 | Informs the window system that the window should stay on bottom of all other windows. | 通知窗口系统该窗口应位于所有其他窗口的底部。 |
Note: On X11, this hint will work only in window managers that support _NET_WM_STATE_BELOW atom. If a window always on the bottom has a parent, the parent will also be left on the bottom. This window hint is currently not implemented for macOS.
注意:在 X11 上,此提示仅适用于支持 _NET_WM_STATE_BELOW atom 的窗口管理器。如果始终位于底部的窗口具有父窗口,则父窗口也将保留在底部。此窗口提示目前尚未针对 macOS 实现。
Note: On Windows, this will work only for frameless or full-screen windows.
注意:在 Windows 上,这仅适用于无框或全屏窗口。
Constant | Value | Description | 我的翻译 |
---|---|---|---|
Qt::WindowTransparentForInput | 0x00080000 | Informs the window system that this window is used only for output (displaying something) and does not take input. Therefore input events should pass through as if it wasn’t there. | 通知窗口系统此窗口仅用于输出(显示某些内容),而不接受输入。因此,输入事件应该像不存在一样传递。 |
Qt::WindowOverridesSystemGestures | 0x00100000 | Informs the window system that this window implements its own set of gestures and that system level gestures, like for instance three-finger desktop switching, should be disabled. | 通知窗口系统此窗口实现自己的一组手势,并且应禁用系统级手势,例如三指桌面切换。 |
Qt::WindowDoesNotAcceptFocus | 0x00200000 | Informs the window system that this window should not receive the input focus. | 通知窗口系统此窗口不应接收输入焦点。 |
Qt::MaximizeUsingFullscreenGeometryHint | 0x00400000 | Informs the window system that when maximizing the window it should use as much of the available screen geometry as possible, including areas that may be covered by system UI such as status bars or application launchers. This may result in the window being placed under these system UIs, but does not guarantee it, depending on whether or not the platform supports it. When the flag is enabled the user is responsible for taking QScreen::availableGeometry() into account, so that any UI elements in the application that require user interaction are not covered by system UI. | 通知窗口系统,在最大化窗口时,它应尽可能多地使用可用的屏幕几何图形,包括系统 UI 可能覆盖的区域,例如状态栏或应用程序启动器。这可能会导致窗口放置在这些系统 UI 下,但不能保证,具体取决于平台是否支持它。启用该标志后,用户负责将 () 考虑在内,以便系统 UI 不会涵盖应用程序中需要用户交互的任何 UI 元素。 |
Qt::WindowType_Mask | 0x000000ff | A mask for extracting the window type part of the window flags. | 用于提取窗口标志的窗口类型部分的掩码。 |