Results 1 to 3 of 3

Thread: How to Call a QDialog in QMainWindow

  1. #1
    Join Date
    Feb 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to Call a QDialog in QMainWindow

    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.

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3.  
    4. MainWindow::MainWindow(QWidget *parent) :
    5. QMainWindow(parent),
    6. ui(new Ui::MainWindow)
    7. {
    8. ui->setupUi(this);
    9. }
    10.  
    11. MainWindow::~MainWindow()
    12. {
    13. delete ui;
    14. }
    15.  
    16. void MainWindow::on_pushButton_clicked()
    17. {
    18. What I Must Write Here to Open My Dialog
    19. }
    To copy to clipboard, switch view to plain text mode 

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


    Thanks

  2. #2
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to Call a QDialog in QMainWindow

    perhaps you might try to read the docs:
    http://doc.qt.nokia.com/4.6/qdialog.html#details

  3. #3
    Join Date
    Nov 2010
    Posts
    30
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: How to Call a QDialog in QMainWindow

    hello ,to go to your new dialog on pushbutton clicked,you should code as below
    void MainWindow:n_pushButton_clicked()
    {
    Dialog a(this);//the name of ur dialog
    a.show();//show your dialog
    a.exec();
    }

Similar Threads

  1. manipulating qmainwindow widget through qdialog
    By xeroblast in forum Qt Programming
    Replies: 1
    Last Post: 16th December 2010, 07:17
  2. Call to QDialog opens 2 windows
    By rdjenner in forum Newbie
    Replies: 5
    Last Post: 14th August 2010, 00:54
  3. QDialog::exec : Recursive call detected.
    By node_ex in forum Qt Programming
    Replies: 4
    Last Post: 29th June 2008, 17:50
  4. QMainWindow child of a QDialog
    By brevleq in forum Qt Programming
    Replies: 2
    Last Post: 16th January 2008, 07:16
  5. QDialog and QMainWindow Data Transfer
    By Ahmad in forum Qt Programming
    Replies: 12
    Last Post: 6th May 2007, 07:02

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.