简体   繁体   English

QSplashscreen背景当我反复单击时会变黑

[英]QSplashscreen background becomes black when I click on it repeatedly

I am using QSplashscreen to display a splashscreen in my application. 我正在使用QSplashscreen在我的应用程序中显示一个QSplashscreen屏幕。 Usually when I click on the splash screen while my applicaiton is loading the splash sccreen disappears. 通常,当我在应用程序加载时单击启动屏幕时,启动屏幕会消失。 I saw that the mousepressevent on Qsplashscreen are made to call hide function of the widget. 我看到mousepressevent上的Qsplashscreen被用来调用小部件的hide函数。

But sometimes when I click on the splashscreen repeatedly the splashscreen background becomes black and if I continue clicking I get a message saying the applicaiton is not reponding. 但是有时,当我反复单击启动屏幕时,启动屏幕背景会变黑,如果我继续单击,则会收到一条消息,指出申请没有响应。 But after a while the app runs fine. 但是一段时间后,该应用程序运行正常。

Why am i sometimes getting a blackbackground on mouse click on splashscreen? 为什么有时我在启动屏幕上单击鼠标时会出现blackbackground? The Qt version i am using is 4.8.5 我正在使用的Qt版本是4.8.5

I was running into this issue as well and I found the best solution was to disable the QSplashScreen that way any user interaction wouldn't fire any events. 我也遇到了这个问题,我发现最好的解决方案是禁用QSplashScreen ,这样任何用户交互都不会触发任何事件。

I tested this on Qt v5.8 but this should also work for v4.8.5 as well. 我在Qt v5.8上进行了测试,但这也适用于v4.8.5。

The reason why are you getting black background and "not responding" messages is probably because your main application need some time to load, that means it's blocking the main event loop .Most people try to disable all events that QSplashScreen implements, but that solution doesn't work. 之所以出现黑色背景和“不响应”消息,可能是因为您的主应用程序需要加载一些时间,这意味着它阻塞了主事件循环。大多数人尝试禁用QSplashScreen实现的所有事件,但是该解决方案无法不行 So the easiest solution is to call QApplication.processEvents from time to time while you are constructing your main application. 因此,最简单的解决方案是在构建主应用程序时不时调用QApplication.processEvents

Note that you should separate your business logic from your presentation logic, exactly because of things like this.It will be a lot easier to solve problems like this. 请注意,正是由于这样的事情,您才应该将业务逻辑与表示逻辑分开,解决这样的问题会容易得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM