PDA

View Full Version : How to Call a QDialog in QMainWindow



mcht_z
9th March 2011, 18:10
Hello, I have a QMainWindow, I want to call a QDialog (its is ready with sorce code, header, and ui file) when push a button.


#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}

MainWindow::~MainWindow()
{
delete ui;
}

void MainWindow::on_pushButton_clicked()
{
What I Must Write Here to Open My Dialog
}


I added dialog.h, dialog.cpp and dialog.ui to my project.


Thanks

schnitzel
9th March 2011, 18:20
perhaps you might try to read the docs:
http://doc.qt.nokia.com/4.6/qdialog.html#details

ranjit.kadam
13th April 2011, 06:43
hello ,to go to your new dialog on pushbutton clicked,you should code as below
void MainWindow::on_pushButton_clicked()
{
Dialog a(this);//the name of ur dialog
a.show();//show your dialog
a.exec();
}