Results 1 to 20 of 27

Thread: How to call a dialog from a mainwindow

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2010
    Posts
    14
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Question How to call a dialog from a mainwindow

    I want to build an interface and I need to link a pushbutton in a mainwindow with a dialog. Both were made in Qt Designer. I tried some answers that I saw in others thread but I think it doesn't help me. So, here it goes my codes:
    Mainwindow: telainicial (.h/.cpp)
    Dialog: simples (.h/.cpp)

    telainicial.h
    Qt Code:
    1. #ifndef TELAINICIAL_H
    2. #define TELAINICIAL_H
    3.  
    4. #include <QMainWindow>
    5. #include "ui_telainicial.h"
    6.  
    7. class telainicial : public QMainWindow, public Ui::telainicial {
    8. Q_OBJECT
    9. public:
    10. telainicial(QWidget *parent = 0);
    11. private slots:
    12. void telasimples();
    13. };
    14.  
    15. #endif // TELAINICIAL_H
    To copy to clipboard, switch view to plain text mode 

    telainicial.cpp
    Qt Code:
    1. #include <QtGui>
    2. #include "telainicial.h"
    3. #include "simples.h"
    4.  
    5. telainicial::telainicial(QWidget *parent) :
    6. QMainWindow(parent)
    7.  
    8. {
    9. setupUi(this);
    10.  
    11. connect(lentesimplesButton, SIGNAL(clicked()), this, SLOT(telasimples()));
    12.  
    13. }
    14.  
    15. void telainicial::telasimples(){
    16.  
    17. //code goes here
    18.  
    19. };
    To copy to clipboard, switch view to plain text mode 

    simples.h
    Qt Code:
    1. #ifndef SIMPLES_H
    2. #define SIMPLES_H
    3.  
    4. #include <QDialog>
    5. #include "ui_simples.h"
    6.  
    7. class simples : public QDialog, public Ui::simples {
    8. Q_OBJECT
    9.  
    10. public:
    11. simples(QWidget *parent = 0);
    12.  
    13. };
    14.  
    15. #endif
    To copy to clipboard, switch view to plain text mode 

    simples.cpp
    Qt Code:
    1. #include "simples.h"
    2. #include <QtGui>
    3.  
    4. simples::simples(QWidget *parent) :
    5. QDialog(parent)
    6.  
    7. {
    8. setupUi(this);
    9. }
    To copy to clipboard, switch view to plain text mode 

    The mains files are similiar like this:
    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "telainicial.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication app(argc, argv);
    7. telainicial mainwindow;
    8. mainwindow.show();
    9. return app.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

    Can somebody help me?
    Last edited by wysota; 18th May 2010 at 21:38. Reason: changed [qtclass] to [code]

Similar Threads

  1. Open Dialog from MainWindow.
    By halvors in forum Qt Programming
    Replies: 8
    Last Post: 1st April 2010, 01:09
  2. Passing Pixmaps between MainWindow and Dialog
    By ramstormrage in forum Qt Programming
    Replies: 28
    Last Post: 20th April 2008, 13:32
  3. Communication between MainWindow and a dialog
    By Backslash in forum Newbie
    Replies: 9
    Last Post: 3rd August 2007, 04:27
  4. Opening a Dialog from a MainWindow FileMenu
    By nbkhwjm in forum Newbie
    Replies: 4
    Last Post: 17th April 2007, 12:24
  5. how to call another dialog using menubar
    By merry in forum Qt Programming
    Replies: 1
    Last Post: 16th April 2007, 14:28

Tags for this Thread

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.