Qt: 窗口 flag, modal, state 属性设置

Qt::WindowFlags

参考:Qt Help

Window flags are a combination of a type (e.g. Qt::Dialog) and zero or more hints to the window system (e.g. Qt::FramelessWindowHint).

A window flag is either a type or a hint.

A type is used to specify various window-system properties for the widget.

A widget can only have one type, and the default is Qt::Widget. However, a widget can have zero or more hints. The hints are used to customize the appearance of top-level windows.

(1)常用几个主要 type:
在这里插入图片描述(2)自定义Top窗口外观 hints

  1. Qt::FramelessWindowHint: Produces a borderless window. The user cannot move or resize a borderless window via the window system.
  2. Qt::X11BypassWindowManagerHint: 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).

(3) 自定义窗口控制

  1. Qt::WindowStaysOnTopHint: 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.
  2. Qt::WindowDoesNotAcceptFocus: Informs the window system that this window should not receive the input focus.

用函数 void setWindowFlags(Qt::WindowFlags type) 来设置窗口 flag

setWindowFlag(Qt::Dialog | Qt::FramelessWindowHint)

QWidget::windowModality

参考:Qt Help

This property holds which windows are blocked by the modal widget.

This property only makes sense for windows.

A modal widget prevents widgets in other windows from getting input. The value of this property controls which windows are blocked when the widget is visible. Changing this property while the window is visible has no effect; you must hide() the widget first, then show() it again.

By default, this property is Qt::NonModal.

enum Qt::WindowModality
在这里插入图片描述
函数 void setWindowModality(Qt::WindowModality windowModality) 来设置该属性。

Qt::WindowState

参考:Qt Help

This enum type is used to specify the current state of a top-level window.

enum Qt::WindowState
flags Qt::WindowStates
在这里插入图片描述The WindowStates type is a typedef for QFlag. It stores an OR combination of WindowState values.

void QWidget::activateWindow()

参考:Qt Help

Sets the top-level widget containing this widget to be the active window.

top-level widget: A widget without a parent widget is always an independent window (top-level widget).

An active window is a visible top-level window that has the keyboard input focus.

This function performs the same operation as clicking the mouse on the title bar of a top-level window.

On X11, the result depends on the Window Manager. If you want to ensure that the window is stacked on top as well you should also call raise(). Note that the window must be visible, otherwise activateWindow() has no effect.

isActiveWindow : const bool

This property holds whether this widget’s window is the active window

The active window is the window that contains the widget that has keyboard focus (The window may still have focus if it has no widgets or none of its widgets accepts keyboard focus).

When popup windows are visible, this property is true for both the active window and for the popup.

By default, this property is false.

void QWidget::raise()

Raises this widget to the top of the parent widget’s stack.

After this call the widget will be visually in front of any overlapping sibling widgets.

void QWidget::lower()

Lowers the widget to the bottom of the parent widget’s stack.

After this call the widget will be visually behind (and therefore obscured by) any overlapping sibling widgets.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值