Results 1 to 6 of 6

Thread: Getting main window to run.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Berkeley California
    Posts
    109
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 1 Time in 1 Post

    Default Getting main window to run.

    I have created a Main Window app in Designer and run qmake to get the ui_n1.h file created. I have subclassed my Main Window object to place my functionality in it. My n1.h file is:

    Qt Code:
    1. class MainWindow : public QMainWindow, public Ui::MainWindow {
    2.  
    3. Q_OBJECT
    4.  
    5. public:
    6.  
    7. MainWindow();
    8. };
    To copy to clipboard, switch view to plain text mode 

    My MainWindow.cpp file is:

    Qt Code:
    1. #include <QtGui>
    2. #include "n1.h"
    3.  
    4. MainWindow::MainWindow() : QMainWindow() {
    5.  
    6. setupUi(this);
    7. }
    To copy to clipboard, switch view to plain text mode 

    My main.cpp is:

    Qt Code:
    1. #include <QApplication>
    2. #include "n1.h"
    3.  
    4. int main(int argc, char *argv[]) {
    5.  
    6. QApplication app(argc, argv);
    7. MainWindow *mainwindow = new MainWindow;
    8. mainwindow->show();
    9. return app.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

    Does this seem right? When I run it nothing happens (or it opens and immediatly closes??).

    Thanks

    Update! Added code tags.
    Last edited by e8johan; 11th October 2006 at 08:16.

Similar Threads

  1. Replies: 5
    Last Post: 4th August 2006, 23:44
  2. Problem in porting Main window on linux
    By jyoti kumar in forum Qt Tools
    Replies: 2
    Last Post: 2nd June 2006, 08:35
  3. How to capture exit slot of main window
    By jyoti kumar in forum Newbie
    Replies: 2
    Last Post: 31st May 2006, 07:06
  4. cannot make a main window modal
    By Dark_Tower in forum Qt Programming
    Replies: 12
    Last Post: 23rd March 2006, 10:21
  5. Main window
    By Michiel in forum Qt Tools
    Replies: 1
    Last Post: 20th March 2006, 23:54

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
  •  
Qt is a trademark of The Qt Company.