nine9hours 0 Newbie Poster

Hi. I am a beginner and i have been facing this problem since Monday. I made a QMainWindow with name window and added an action in it. So when a user clicks the action, the QDialog dialog is displayed. In dialog i take input from user and then return it to window for display. I have set QMainWindow window as parent to QDialog dialog. Now How can i call the function of QMainWindow when OK button is clicked. Here is the code.
Please Please Explain me how to call QMainWindow functions from its child dialog in SIMPLE coding. I will really be thankful to you people.
this is .cpp file of QDialog

#include "itemdialog.h"

#include "ui_itemdialog.h"

#include "mainwindow.h"

ItemDialog::ItemDialog(QWidget *parent) :


ui(new Ui::ItemDialog)



setWindowTitle("Status Dialog");




delete ui;


void ItemDialog::on_pushButton_clicked()


MainWindow obj;



Header file of QDialog


#include <QDialog>

class MainWindow;

namespace Ui {

class ItemDialog;


class ItemDialog : public QDialog




explicit ItemDialog(QWidget *parent = 0);


private slots:

void on_pushButton_clicked(); // when OK button is clicked this function is called automatically


Ui::ItemDialog *ui;


#endif // ITEMDIALOG_H

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.