I am trying to learn QT creator and have searched and read the forum and several other areas but I must be missing something. I am writing a program that will have a main window and then widgets (dialog forms) that I want to open and close inside the main window. I am able to create the forms and have a button open the second form. The problem is that the form does not open as a child of the main window. I think I might need to create some sort of container in the main form and pass a pointer to that container? I am lost at how to do this. I am using QT Creator 1.2.1 based on QT 4.5.2. What am I missing? Here is the code!
MainWindow.h
Code:
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> namespace Ui { class MainWindow; } { Q_OBJECT public: ~MainWindow(); protected: private: Ui::MainWindow *ui; private slots: void on_btnNextPage_clicked(); //Identify a pointer here? Buy how? };
MainWindow.cppCode:
#include "mainwindow.h" #include "ui_mainwindow.h" #include "page2.h" ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; } { switch (e->type()) { ui->retranslateUi(this); break; default: break; } } void MainWindow::on_btnNextPage_clicked() { Page2* page2 = new Page2 () ; // Page2* page2 = new Page2 (this) ; ?? page2->exec(); }