QSplashScreen after startup?
-
The documentation for QSplashScreen indicates that it is meant to be used during initialization before the main window is displayed, but is there any rule against using it afterward? I have an application that loads a format file during startup, but the user can load a different one from the user interface while the application is running. I am trying to reuse the QSplashScreen for this, but I find that when I call showMessage() on the splash screen while the main window is displayed, the application crashes.
I am using Qt 5.15.2. The crash only happens when I am running on Windows 7. On Win 10, it seems to work okay.
-
You can use it anywhere and anywhen in your code. If it crashes then you most likely doing something wrong - please provide a minimal, compilable example of your problem.
-
@Christian-Ehrlicher You were right. My application connects to a radar system via Ethernet and receives data through a TCP socket. I was trying to load the data values into the display controls that were being refreshed by the routine that reloads the format file, so the controls weren't ready.
I'm still baffled as to why this only caused the application to crash when I called showMessage() on the splash screen. I guess it was a timing issue?
-
@richferrara One must look at the backtrace to really find out. My first though showMessage() spins an event loop but this is not the case. Any chance that it was called from another thread?
-
@Christian-Ehrlicher I don't know. It appears I'm still having problems with it. I'm running on my desk PC that doesn't use the Ethernet connection, but it still causes the application to crash at seemingly random times. At this point I'll probably go with just implementing my own progress indicator as a widget or something else.
-
@Christian-Ehrlicher I removed the QSplashScreen and replaced it with my own dialog containing a progress bar. But now when I try updating the progress bar status while the file is loading, the application still crashes. So it's not something specific to QSplashScreen.
Basically all I'm trying to do is:
- The user clicks a pushbutton on the GUI to load or import a file.
- The slot for the pushbutton shows a file dialog and allows the user to select a file.
- The slot shows the progress screen and starts parsing the file in a loop.
- Each time through the loop, the slot updates the progress bar value.
That's all. But updating the progress bar is causing the application to crash, just like setting the message on the splash screen did.
There are no other threads running in my application. I turned off the Ethernet connection also but it doesn't help.
-
@richferrara said in QSplashScreen after startup?:
So it's not something specific to QSplashScreen.
It would be very unlikely since
QSplashScreen
is just anotherQWidget
and unless you messed up some pointers, it should not impact your application.Basically all I'm trying to do is:
The user clicks a pushbutton on the GUI to load or import a file.
The slot for the pushbutton shows a file dialog and allows the user to select a file.
The slot shows the progress screen and starts parsing the file in a loop.
Each time through the loop, the slot updates the progress bar value.That's all. But updating the progress bar is causing the application to crash, just like setting the message on the splash screen did.
Hard to say just from this "pseudo code" description.
The slot shows the progress screen and starts parsing the file in a loop.
Does it already crash on the first update call? Or does it run and update for some seconds and crashes later?
If the former is true, check (or show) how the dialog is created and verify that the instance is still "alive" when sending the update calls. (checking how everything's connected might also help)