• 14850阅读
  • 2回复

【原创】关于Qt::WidgetFlags的问题 [复制链接]

上一主题 下一主题
离线guyansrg
 

只看楼主 倒序阅读 楼主  发表于: 2005-12-30
— 本帖被 XChinux 执行加亮操作(2008-11-30) —
月初我提了一个问题:
如何在窗口标题栏上添加“最大化”和“最小化”按钮(Qt4)

XChinux斑竹 解答了我的提问。但有误导之嫌,他说“看一看setWindowFlags()这个函数。”
我被唬得晕晕的,晕晕的查setWindowFlags()这个函数查了将近一个月。结果就是没有。
只是查到Qt::WidgetFlags这个函数。

为了方便大家,我把这一部分的帮助文件的内容贴出来。希望能对大家编成有些帮助。
Qt::WidgetFlags
This enum type is used to specify various window-system properties for the widget. They are fairly unusual but necessary in a few cases. Some of these flags depend on whether the underlying window manager supports them. (See the toplevel example for an explanation and example of their use.)
The main types are
Qt::WType_TopLevel - indicates that this widget is a top-level widget, usually with a window-system frame and so on.
Qt::WType_Dialog - indicates that this widget is a top-level window that should be decorated as a dialog (i.e. typically no maximize or minimize buttons in the title bar). If you want to use it as a modal dialog it should be launched from another window, or have a parent and this flag should be combined with WShowModal. If you make it modal, the dialog will prevent other top-level windows in the application from getting any input. WType_Dialog implies WType_TopLevel. We refer to a top-level window that has a parent as a secondary window. (See also WGroupLeader.)
Qt::WType_Popup - indicates that this widget is a popup top-level window, i.e. that it is modal, but has a window system frame appropriate for popup menus. WType_Popup implies WType_TopLevel.
Qt::WType_Desktop - indicates that this widget is the desktop. See also WPaintDesktop below. WType_Desktop implies WType_TopLevel.
There are also a number of flags which you can use to customize the appearance of top-level windows. These have no effect on other windows:
Qt::WStyle_Customize - indicates that the WStyle_* flags should be used to build the window instead of the default flags.
Qt::WStyle_NormalBorder - gives the window a normal border. This cannot be combined with WStyle_DialogBorder or WStyle_NoBorder.
Qt::WStyle_DialogBorder - gives the window a thin dialog border. This cannot be combined with WStyle_NormalBorder or WStyle_NoBorder.
Qt::WStyle_NoBorder - produces a borderless window. Note that the user cannot move or resize a borderless window via the window system. This cannot be combined with WStyle_NormalBorder or WStyle_DialogBorder. On Windows, the flag works fine. 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. With WX11BypassWM, you can 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 setActiveWindow() manually).
Qt::WStyle_NoBorderEx - this value is obsolete. It has the same effect as using WStyle_NoBorder.
Qt::WStyle_Title - gives the window a title bar.
Qt::WStyle_SysMenu - adds a window system menu.
Qt::WStyle_Minimize - adds a minimize button. Note that on Windows this has to be combined with WStyle_SysMenu for it to work.
Qt::WStyle_Maximize - adds a maximize button. Note that on Windows this has to be combined with WStyle_SysMenu for it to work.
Qt::WStyle_MinMax - is equal to WStyle_Minimize|WStyle_Maximize. Note that on Windows this has to be combined with WStyle_SysMenu to work.
Qt::WStyle_ContextHelp - adds a context help button to dialogs.
Qt::WStyle_Tool - makes the window 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. It there is a parent, the tool window will always be kept on top of it. If there isn't a parent, you may consider passing WStyle_StaysOnTop 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 WStyle_NoBorder.
Qt::WStyle_StaysOnTop - 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 WX11BypassWM for this flag to work correctly.
Qt::WStyle_Dialog - indicates that the window is a logical subwindow of its parent (i.e. a dialog). The window will not get its own taskbar entry and will be kept on top of its parent by the window system. Usually it will also be minimized when the parent is minimized. If not customized, the window is decorated with a slightly simpler title bar. This is the flag QDialog uses.
Qt::WStyle_Splash - indicates that the window is a splash screen. On X11, we try to follow NETWM standard for a splash screen window if the window manager supports is otherwise it is equivalent to WX11BypassWM. On other platforms, it is equivalent to WStyle_NoBorder | WMacNoSheet | WStyle_Tool | WWinOwnDC
Modifier flags:
Qt::WDestructiveClose - makes Qt delete this widget when the widget has accepted closeEvent(), or when the widget tried to ignore closeEvent() but could not.
Qt::WPaintDesktop - gives this widget paint events for the desktop.
Qt::WPaintUnclipped - makes all painters operating on this widget unclipped. Children of this widget or other widgets in front of it do not clip the area the painter can paint on.
Qt::WPaintClever - indicates that Qt should not try to optimize repainting for the widget, but instead pass on window system repaint events directly. (This tends to produce more events and smaller repaint regions.)
Qt::WMouseNoMask - indicates that even if the widget has a mask, it wants mouse events for its entire rectangle.
Qt::WStaticContents - indicates that the widget contents are north-west aligned and static. On resize, such a widget will receive paint events only for the newly visible part of itself.
Qt::WNoAutoErase - indicates that the widget paints all its pixels. Updating, resizing, scrolling and focus changes should therefore not erase the widget. This allows smart-repainting to avoid flicker.
Qt::WResizeNoErase - this value is obsolete; use WNoAutoErase instead.
Qt::WRepaintNoErase - this value is obsolete; use WNoAutoErase instead.
Qt::WGroupLeader - makes this window a group leader. A group leader should not have a parent (i.e. it should be a top-level window). Any decendant windows (direct or indirect) of a group leader are in its group; other windows are not. If you show a secondary window from the group (i.e. show a window whose top-most parent is a group leader), that window will be modal with respect to the other windows in the group, but modeless with respect to windows in other groups.
Miscellaneous flags
Qt::WShowModal - see WType_Dialog
Internal flags.
Qt::WNoMousePropagation
Qt::WStaticContents
Qt::WStyle_Reserved
Qt::WSubWindow
Qt::WType_Modal
Qt::WWinOwnDC
Qt::WX11BypassWM
Qt::WMacNoSheet
Qt::WMacDrawer
Qt::WStyle_Mask
Qt::WType_Mask
[ 此贴被XChinux在2005-12-30 09:25重新编辑 ]
离线XChinux

只看该作者 1楼 发表于: 2005-12-30

二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线icelee
只看该作者 2楼 发表于: 2008-11-25
Qt::WidgetFlags

这个枚举类型是用来指定窗口部件的窗口系统属性的。它们通常情况下没用,但是在一些场合是必需的。这些标记中的一些依赖于窗口管理器是否支持它们。

主要类型有

Qt::WType_TopLevel - 表明这个窗口部件是顶级的,通常有一个窗口系统框架和其它的。
Qt::WType_Dialog - 表明这个窗口部件是顶级的,并且应该被修饰为一个对话框(比如,作为特色,在标题栏中没有最大化和最小化按钮)。如果你想使用它作为一个模式对话框,它应该从另一个窗口中被运行,或者有一个父窗口并且这个标记必须和WShowModal一起使用。如果你使用了模式对话框,这个对话框将会防止应用程序的其它顶级窗口获得任何输入。WType_Dialog隐含了WType_TopLevel。我们指的是作为一个二级窗口作为顶级窗口需要有父窗口。(请参考WGroupLeader。)
Qt::WType_Popup - 表明这个窗口部件是一个弹出式的顶级窗口部件,比如它是模式的,但是供弹出菜单使用的窗口系统框架。WType_Popup隐含了WType_TopLevel。
Qt::WType_Desktop - 表明这个窗口部件是着明。请参考下面的WPaintDesktop。WType_Desktop隐含了WType_TopLevel。
这里还有大量的标记可以用来自定义顶级窗口的外观。这些对于其它窗口没有任何效果的:

Qt::WStyle_Customize - 表明WStyle_*标记应该被用来替换默认标记来构建窗口。
Qt::WStyle_NormalBorder - 给窗口一个普通边界。这个不能和WStyle_DialogBorder或WStyle_NoBorder一起使用。
Qt::WStyle_DialogBorder - 给窗口一个窄的对话框边界。这个不能和WStyle_NormalBorder或WStyle_NoBorder。
Qt::WStyle_NoBorder - 产生一个没有边界的窗口。注意:用户不可以通过窗口系统来移动或者重新定义无边界窗口的大小。这个标记不可以和WStyle_NormalBorder或WStyle_DialogBorder一起使用。在Windows中,这个标记正常工作。在X11中,这个标记的结果取决于窗口管理器和它们对于MOTIF和/或NETWM提示的理解的能力:现在存在的现代窗口管理器中的绝大部分都可以处理这些。通过WX11BypassWM,你可以完全地绕过窗口管理器。这样的结果就是无边界窗口根本无法被管理了(比如,除非你手工地调用setActiveWindow()就无法获得键盘输入)。
Qt::WStyle_NoBorderEx - 这个值是废弃的。它的效果和使用WStyle_NoBorder是一样的。
Qt::WStyle_Title - 给窗口一个标题栏。
Qt::WStyle_SysMenu - 添加一个窗口系统菜单。
Qt::WStyle_Minimize - 添加一个最小化按钮。注意:在Windows下,为了使它能够正常工作,它必须和WStyle_SysMenu一起组合使用。
Qt::WStyle_Maximize - 添加一个最大化按钮。注意:在Windows下,为了使它能够正常工作,它必须和WStyle_SysMenu一起组合使用。
Qt::WStyle_MinMax - 和WStyle_Minimize|WStyle_Maximize是一样的。注意:在Windows下,为了使它能够正常工作,它必须和WStyle_SysMenu一起组合使用。
Qt::WStyle_ContextHelp - 添加一个上下文帮助按钮到对话框上。
Qt::WStyle_Tool - 使这个窗口变为一个工具窗口。一个工具窗口经常是一个比含有正常标题栏和休息的窗口更小的窗口,很典型的用于工具按钮的集合。如果它有一个父窗口,工具窗口将总被放在它的上面。如果它没有父窗口,你需要考虑同时传递一个WStyle_StaysOnTop。如果窗口系统支持它,一个工具窗口将会被使用更亮的框架来修饰。它也可以和WStyle_NoBorder一起组合使用。
Qt::WStyle_StaysOnTop - 通知窗口系统这个窗口应该放在所有其它窗口的上面。
Qt::WStyle_Dialog - 表明这个窗口是它的父窗口(比如,一个对话框)的逻辑子窗口。这个窗口将没有自己的任务栏条目并且通过窗口系统它将被保持在它的父窗口上面。通常当它的父窗口最小化时,它也最小化。如果没有自定义,这个窗口将会被一个稍微简单一些的标题栏修饰。这个标记被QDialog使用。
修饰标记:

Qt::WDestructiveClose - 当窗口部件已经接收到closeEvent(),或者当窗口部件试图忽略closeEvent()但不能的时候,使Qt删除这个窗口部件。
Qt::WPaintDesktop - 把桌面的绘制事件给这个窗口部件。
Qt::WPaintUnclipped - 使在这个窗口部件上的所有的绘制操作都不能被省略。在它前面的这个窗口部件的子窗口部件或者其它窗口部件不能把它上面的绘制区域省略掉。
Qt::WPaintClever - 表明Qt不应该试图优化重绘这个窗口部件,但是相反,在窗口系统上直接传递重绘事件。(这样往往会产生更多的事件和更小的重绘区域。)
Qt::WResizeNoErase - 表明重新定义窗口部件的大小不应该删除它。这样允许比较聪明的重绘来避免闪烁。
Qt::WMouseNoMask - 表明即使这个窗口部件有一个障板,它想获得它的整个矩形区域内的鼠标时间。
Qt::WStaticContents - 表明这个窗口部件的内容是向西北方向对齐的并且是静态度。当重新定义大小的时候,这个窗口部件将只接收它自己之内的新的可见的部分的绘制事件。
Qt::WRepaintNoErase - 表明这个窗口绘制所有的象素。更新、滚动和焦点改变都不会因此删除这个窗口部件。这样允许比较聪明的重绘来避免闪烁。
Qt::WGroupLeader - 使这个窗口为一个组领导。一个组领导不应该有父窗口(比如,它应该是一个顶级窗口)。组领导的任何子孙窗口(直接的或见解的)都在它这个组里,其它窗口不在。如果你从一个组中显示一个次要的窗口(比如,显示一个最上端父窗口为组领导的窗口),对于组内其它窗口它是模式的,但对于组外的它是非模式的。
程序人生
快速回复
限100 字节
 
上一个 下一个