I see two ways of doing this.
Sophisticated:
void MainWindow::showEvent(QShowEvent *e)
{
QMainWindow::showEvent(e);
static bool firstStart = true;
if (firstStart)
{
emit startJob();
firstStart = false;
}
}
And easy one (suitable only, if you show main window right after creating):
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
...
QTimer::singleShot(500, this, SLOT(job()));
}
Update:
Like Chris
said, showEvent
is much more appropriate here, than paintEvent
.