3

I am using QSplashscreen to display a splashscreen in my application. 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.

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? The Qt version i am using is 4.8.5

sajas
  • 1,599
  • 1
  • 17
  • 39
  • 1
    Do you process events during the display of the splashscreen? – OnWhenReady Jun 03 '14 at 14:46
  • @DominikSelzer Thanks for the reply. I was not calling processevents from my app. I don't want the splash screen to get updated with any information other than display a png file. For calling processevent, I added a non-single-shot timer and on it's timeout I kept calling process event. The time interval i set was of 100ms. Still the splashscreen goes black on clicking on it repeatedly. – sajas Jun 04 '14 at 08:18
  • I hope i get it right, but have you checked, if the timer is really able to shot if the event loop of the app cannot be processed (e.g. while doing some heavy lifting during the splash screen). Have you tried to connect the timer to a slot and check if it gets processed. – OnWhenReady Jun 04 '14 at 12:40
  • @DominikSelzer You meant like logging something during timeout? I will try that. One more question. In my application, during loading if I kept clcking on the app window ( somewhere else other than splash screen) the app becomes non responsive and even if I kept on clicking on the window, the app resumes after sometime. But while the app is non responsive I go and click on the splash screen, a pop up appears saying app is not responding and i should either close it or wait. If i wait the app runs normal. Why do i get this pop up when i click on splash screen? – sajas Jun 04 '14 at 14:43
  • You are blocking the main event loop. That is (i guess it since i do not really know what you are doing) why the OS (is it Windows?) thinks the application is frozen. – OnWhenReady Jun 04 '14 at 17:10
  • @DominikSelzer Is there any way I can disable all the events ,meaning even before using show of the splash screen i will disable all the events.I already tried using setDisable(true),but that did not seem to do the job for me.Any suggestions??? – sajas Jun 05 '14 at 09:52
  • Could you please provide information what you are actually doing. There are two possibilities to prevent the app to freeze: 1) Calling 'processEvents' regularly. This will fail if e.g. a slow method will block the flow for too long. 2) Using threads to do the heavy lifting while keeping the main thread (GUI thread) responsive. – OnWhenReady Jun 05 '14 at 10:23

2 Answers2

2

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.

I tested this on Qt v5.8 but this should also work for v4.8.5 as well.

Stekcoptoh
  • 21
  • 3
0

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. So the easiest solution is to call QApplication.processEvents from time to time while you are constructing your main application.

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.

sup
  • 323
  • 1
  • 12