mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
void foo();
~MainWindow();
private slots:
void on_pushButton_1_clicked();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
main.cpp
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow
w.show(); //It display blank window without any buttons or content
w.foo(); //It execute before the window is rendered
return a.exec();
}
w.show() invokes MainWindow constructor. I would like to call function foo after the window is rendered completely. So, that I can perform actions on it. But after w.show() it looks like image1 and then calls foo which can't do anything because there is no interface. I removed w.foo() and set the break point at w.show(). While debugging at w.show() it look like below image1 and after return a.exec() it looks like image2 with full interface. The code for all these functions are written in mainwindow.cpp and gui in mainwindow.ui.
EDIT foo function
void MainWindow::foo()
{
ui->statusbar->clearMessage();
ec.pause();
ec.start(); //start thread
ec.wait(); //wait until thread ends
new TreeOperations();
}