execute function after widget is displayed.
Hello.
I have a litle problem.
For testing purposes imagine a simple app witch a single button.
Clicking this button creates new window (basic QDialog), that contains fiew QLineEdits and QLabel's.
Code for that window also contains a time - consuming function.
Problem is: i would like to deley execution of this function till mentioned window is fully drawn.
Currently function is exeuted before window appears, so - more time this function needs - more time it takes to show my window.
My target is, as i have mentioned:
Application starts -> user clicks on the button -> new (children) window appears -> function included in this winow code is executed.
Thanks in advance for any help :)
PS:
I hope my English is readable enough.
Re: execute function after widget is displayed.
You can use a 0 millisecond single shot timer started from the constructor of the dialog to call the function (as a slot) after the program returns to the event loop.
Code:
MyDialog()
{
...
QTimer::singleShot(0,
this,
SLOT(doLongRunningThings
()));
}
/* public or private slot */
void doLongRunningThings()
{
}
Re: execute function after widget is displayed.
Thank you very much :)
You idea work's perfect in my case.