Results 1 to 4 of 4

Thread: Starting building QT projects

  1. #1
    Join Date
    Sep 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Red face Starting building QT projects

    Hello,

    I am new to QT.. well my question is probably is a basic C++ thingy anyway..

    I want to develop the application and having in mind that i should make each window in it's own c++ file, for a start i want to have the main.cpp to only contain the basic application setup, then develop the mainwindow in another c++ file, for example:

    main.cpp:
    Qt Code:
    1. #include "main.h"
    2. #include <QApplication>
    3. int main(int argc, char *argv[])
    4. {
    5. QApplication a(argc, argv);
    6.  
    7. return a.exec();
    8. }
    To copy to clipboard, switch view to plain text mode 

    then have a mainwindow class in another c++ file

    mainWindow.cpp
    Qt Code:
    1. #include <QMainWindow>
    2.  
    3. class MainWindow : public QMainWindow
    4. {
    5. public:
    6. MainWindow();
    7.  
    8. };
    9.  
    10. MainWindow::MainWindow()
    11. {
    12. setWindowTitle("Test");
    13. }
    To copy to clipboard, switch view to plain text mode 

    now i want to know how to add the MainWindow class to the app in main.cpp? i mean how to add it to the application then call it from there?

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Starting building QT projects

    Thats easy.

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

  3. #3
    Join Date
    Sep 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Starting building QT projects

    Quote Originally Posted by yogeshgokul View Post
    Thats easy.

    Qt Code:
    1. #include "main.h"
    2. #include <QApplication>
    3. #include "MainWindow.h"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication a(argc, argv);
    8. MainWindow mw;
    9. mw.show();
    10. return a.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 
    thank you, that's what i did, but i get this error:
    C:/Qt/2009.03/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/locale_facets.tcc:2498: undefined reference to `vtable for MainWindow'

  4. #4
    Join Date
    Sep 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Starting building QT projects

    nevermind, i sorted it out, thank you very much

Similar Threads

  1. Replies: 8
    Last Post: 28th October 2013, 01:08
  2. Eclipse Integration and program not starting
    By Cruz in forum Installation and Deployment
    Replies: 1
    Last Post: 16th January 2009, 22:32
  3. Building debug version under VS2008
    By KenW in forum Installation and Deployment
    Replies: 1
    Last Post: 2nd May 2008, 19:09

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.