windows - Windows 和 QWidget::activateWindow() 中的事件窗口

标签 windows qt window-managers foreground

QWidget::activateWindow() 的 Qt 文档指出:

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.

但是,Skype 似乎违背了这条规则。如果 Skype 正在运行但不是事件应用程序,我可以从开始菜单启动它,它将现有实例带到前台,激活它并获取输入焦点。

如何做到这一点?

最佳答案

(注意:这特定于 QtSingleApplication 的工作方式)

对于我的问题,解决方案非常简单。只需在应用程序开始时调用 AllowSetForegroundWindow(ASF_ANY);,原始进程就可以通过使用 SetForegroundWindow() 将自己带到前台。没有奇怪的技巧,只需添加一行代码,也不需要修改 QtSingleApplication。

关于windows - Windows 和 QWidget::activateWindow() 中的事件窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3316350/

相关文章:

windows - 在 Windows 操作系统中打开文件时将默认程序重定向到另一个程序

windows - USB 未在 mac OS 上的 oracle virtualbox 中检测到

CryptEncrypt 忽略 HASH?

c# - 更新大于 1GB 的文件?

mysql - SELECT LAST_INSERT_ID() 返回零

c++ - 在 cv::mat 和 Qimage 之间转换会使程序崩溃

linux - 直接打开到 Xserver 的套接字

ubuntu - 如何让一个窗口永远在最上面?

c++ - 不同平台的 QT 应用程序中的类型是否具有相似的大小?

c - 如何在使用 XCB 启动新应用程序时获取事件