月初我提了一个问题:
如何在窗口标题栏上添加“最大化”和“最小化”按钮(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重新编辑 ]