Code:
#include <QApplication>
#include <QDialog>
#include <QPushButton>
class TextToSpeechDialog2 : public QDialog {
Q_OBJECT
public:
TextToSpeechDialog2(void) {
setWindowTitle("TextToSpeechDialog2"); setFixedSize(320, 240);
}
};
class TextToSpeechDialog1 : public QDialog {
Q_OBJECT
public:
TextToSpeechDialog1(void)
: QDialog(), nextButton("Next", this) //initialize next button
{
setWindowTitle("TextToSpeechDialog1"); setFixedSize(320, 240);
QObject::connect(&nextButton, SIGNAL(clicked()), this, SLOT(nextClicked()));
}
public slots:
void nextClicked(void) {
hide(); //hide TextToSpeechDialog1
dialog2.show(); //show TextToSpeechDialog2
}
private:
TextToSpeechDialog2 dialog2;
QPushButton nextButton;
};
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
TextToSpeechDialog1 dialog1;
dialog1.show();
return app.exec();
}
Sorry, I don't get why you'll need the global function especially why you put that inside the main which will be executed after your first dialog shown up, you may try the code above.