在Qt中显示窗口,而不窃取焦点 [英] Show window in Qt without stealing focus

查看:1249
本文介绍了在Qt中显示窗口,而不窃取焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户没有使用第二个显示器时,我使用Qt库在第二个显示器上显示幻灯片。一个例子是用户在第一个监视器中玩游戏,并在第二个监视器中显示幻灯片。

I'm using the Qt library to show a slideshow on the second monitor when the user isn't using the second monitor. An example is the user playing a game in the first monitor and showing the slideshow in the second monitor.

问题是当我在Qt中打开一个新窗口时自动从之前的应用程序窃取焦点。有没有办法防止这种情况发生?

The problem is that when I open a new window in Qt, it automatically steals the focus from the previous application. Is there any way to prevent this from happening?

推荐答案

我花了一段时间才发现它, c $ c> setAttribute(Qt :: WA_ShowWithoutActivating);

It took me a while to find it but I found it: setAttribute(Qt::WA_ShowWithoutActivating);

这会强制窗口不激活。即使使用 Qt :: WindowStaysOnTopHint 标志

This forces the window not to activate. Even with the Qt::WindowStaysOnTopHint flag

这篇关于在Qt中显示窗口,而不窃取焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆