码迷,mamicode.com
首页 > 其他好文 > 详细

Qt 单击任务栏图标实现最小化

时间:2018-08-31 00:28:55      阅读:322      评论:0      收藏:0      [点我收藏+]

标签:方法   windows   cpp   work   ini   href   ram   form   turn   

Qt中对于窗口边框的设置一般用到setWindowFlags函数。

void setWindowFlags(Qt::WindowFlags type)

 

如果只setWindowFlags(Qt::FramelessWindowHint);
去掉边框,此时会发现,当程序打开后,单击任务栏的按钮,会发现无法最小化,隐藏窗口。
解决的方法是:
setWindowFlags(Qt::Window|Qt::FramelessWindowHint |Qt::WindowSystemMenuHint|Qt::WindowMinimizeButtonHint|Qt::WindowMaximizeButtonHint);
再次测试,发现边框去掉了,而且鼠标点击任务栏图标,也可以显示和隐藏窗口了。
 
附:
Qt::Widget

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

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 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::FramelessWindowHint

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.

Qt::CustomizeWindowHint Turns off the default window title hints.
Qt::WindowTitleHint Gives the window a title bar.
Qt::WindowSystemMenuHint

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.

Qt::WindowMinimizeButtonHint

Adds a minimize button.

On some platforms this implies Qt::WindowSystemMenuHint for it to work.

Qt::WindowMaximizeButtonHint

Adds a maximize button.

On some platforms this implies Qt::WindowSystemMenuHint for it to work.

Qt::WindowMinMaxButtonsHint

Adds a minimize and a maximize button.

On some platforms this implies Qt::WindowSystemMenuHint for it to work.

Qt::WindowCloseButtonHint

Adds a close button.

 On some platforms this implies Qt::WindowSystemMenuHint for it to work.

 
 

Qt 单击任务栏图标实现最小化

标签:方法   windows   cpp   work   ini   href   ram   form   turn   

原文地址:https://www.cnblogs.com/granx/p/9563315.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!