欢迎访问Ningto's博客

Menu
  • 首页
  • 归档
  • 关于
  • 书签
  • 必应壁纸
  • IT聚合
  • 工具
    • 我的工具列表
    • 我的网盘
    • 必应每日壁纸API
    • Html转Markdown
    • 仙尘光标
Menu

Qt什么时候用activateWindow

最后更新 2019-03-05 09:00:48   阅读量 3104

Table of Contents

  • 1. void-qwidget-show
  • 2. void-qwidget-shownormal
  • 3. void-qwidget-raise
  • 4. void-qwidget-activatewindow

Qt什么时候用activateWindow

通常我们使用show来显示窗口,使用raise将窗口显示在最前面。
遇到的问题是,当在主窗口中打开一个子窗口时,如果这个窗口之前已经创建好了,它只是不在最前面被遮挡了,这时候要把它显示在前面使用show和raise是可以的。但是会带来一个问题,如果在当前窗口上没有做任何操作就直接点击主窗口,此时子窗口还是在前面,遮挡住了主窗口。除非你在子窗口上点击一下再点击主窗口就可以了。

解决上面问题的方法其实就是使用activateWindow和raise。

可以参考下面的API解释。

void QWidget::show()

Shows the widget and its child widgets. This is equivalent to calling showFullScreen(), showMaximized(), or setVisible(true), depending on the platform's default behavior for the window flags.

void QWidget::showNormal()

Restores the widget after it has been maximized or minimized. Calling this function only affects windows.

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. Note: When using activateWindow(), you can call this function to ensure that the window is stacked on top.

void QWidget::activateWindow()

Sets the top-level widget containing this widget to be the active window. 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. On Windows, if you are calling this when the application is not currently the active one then it will not make it the active window. It will change the color of the taskbar entry to indicate that the window has changed in some way. This is because Microsoft does not allow an application to interrupt what the user is currently doing in another application.

(转载本站文章请注明作者和出处:泞途 - ningto.com)

下一篇 – mysql CPU一直占用过高
上一篇 – MAC WIFI连上了但是不能上网

  1. Windows
  2. Qt
  3. C/C++

toningto@outlook.com

推荐文章

Effective Python

Python的几种函数参数类型

标签云

Mac React Database Qt Node.js Javascript Product C/C++ Python Bug Tools Windows Linux Tips Design Go IOS MongoDB Shell Android Mobile Life Java Web MQ Others Boost

推广链接

【腾讯云】云产品限时秒杀,爆款1核2G云服务器,首年99元

多谢支持,用了好几年,服务很稳定支持多设备!

其他

文章RSS

Copyright © 2016 Welcome To Ningto Blog | 鄂ICP备17003086号-2