What do you mean by "fully loaded"?
You can trigger some activity when the program returns to the Qt event loop with a single-shot timer at the end of the constructor:
#include <QtGui>
#include <QDebug>
Q_OBJECT
public:
label1
= new QLabel("Label 1",
this);
label2
= new QLabel("Label 2",
this);
layout->addWidget(label1);
layout->addWidget(label2);
central->setLayout(layout);
setCentralWidget(central);
QTimer::singleShot(0,
this,
SLOT(doLater
()));
}
public slots:
void doLater() {
// Executes when event loop reached (after show in this case)
label2->setText("I've been changed");
}
private:
};
int main(int argc, char *argv[])
{
MainWindow m;
m.show();
return app.exec();
}
#include "main.moc"
#include <QtGui>
#include <QDebug>
class MainWindow: public QMainWindow {
Q_OBJECT
QLabel *label1;
QLabel *label2;
public:
MainWindow(QWidget *p = 0): QMainWindow(p) {
QWidget *central = new QWidget(this);
label1 = new QLabel("Label 1", this);
label2 = new QLabel("Label 2", this);
QVBoxLayout *layout = new QVBoxLayout(central);
layout->addWidget(label1);
layout->addWidget(label2);
central->setLayout(layout);
setCentralWidget(central);
QTimer::singleShot(0, this, SLOT(doLater()));
}
public slots:
void doLater() {
// Executes when event loop reached (after show in this case)
label2->setText("I've been changed");
}
private:
};
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow m;
m.show();
return app.exec();
}
#include "main.moc"
To copy to clipboard, switch view to plain text mode
Bookmarks