showMessage and updating progress bar, emitting signals even after splash screen is gone when using connect().
-
Re: How to update progress bar?
I am updating the progress bar using connect(senderInstance, &SenderClass::signalMethod,
receiverInstance, &ReceiverClass::slotMethod) method only.
But this is some how disturbing the way of loading SEQENCE of other start up dll's.
When I put logs I am seeing the slotMethod is still invoked by QT after the splash screen is hidden and out of focus..I am using below code for updating progress bar
if (_progressBar != nullptr)
{ _progressBar->setValue(_progressBar->value() + progress);
_progressBarLabel->repaint();
repaint();
}
After replacing the repaint() with update(), the issue is gone. And I reduced some signal emits also.
What can be the cause of this issue? -
@Madhavi said in showMessage and updating progress bar, emitting signals even after splash screen is gone when using connect().:
What can be the cause of this issue?
Of which issue actually? Please explain better.
Why do you call repaint at all?
This should not be needed if implemented properly.If the issue is "When I put logs I am seeing the slotMethod is still invoked by QT after the splash screen is gone" then disconnect the connection you did before or delete the progressBar...
-
I have QSplashsceen class, where I need to update progress bar(With Message) to indicate the progress of dll's which are loading and running.
So I am connecting in main.cpp like below
connect(senderInstance, &SenderClass::signalMethod,
receiverInstance, &ReceiverClass::slotMethod)And emitting signals while loading binaries. In the slot I have the below code
if (_progressBar != nullptr)
{ _progressBar->setValue(_progressBar->value() + progress);
_progressBarLabel->repaint();
repaint();
}With this the startup dll's loading sequence is modified. And getting sync up issues .
By replacing repaint() with update(), the issues are gone. But why is this difference?How updating splash screen progress bar with repaint() effecting the sequence of dll loading, which ultimately causing the sync up issues.
load_dlls()
while(list of dll's) //loops through the list of dll's
{
runDlls();
emit updateprogress();
emit showMessage();
}
} -
@Madhavi said in showMessage and updating progress bar, emitting signals even after splash screen is gone when using connect().:
load_dlls()
while(list of dll's) //loops through the list of dll's
{
runDlls();
emit updateprogress();
emit showMessage();
}You're blocking the event loop !
Your design is wrong, you should do something like that instead:void loadNextDll() // must be a slot { if(list not empty) { load top dll in the list emit what ever ... QTimer::singleShoot(loadNextDll) } }
-
@Madhavi said in showMessage and updating progress bar, emitting signals even after splash screen is gone when using connect().:
while(list of dll's)
Any loop like this will block. You emit messages but do not allow the Qt event loop to run. Hence @mpergand's suggestion.