Results 1 to 5 of 5

Thread: create a class

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2013
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default create a class

    hi
    i want to create my own class and use it in another project. I'm following a Tutorial but i'm blocked now. Look what the tuto did
    First he made a project FenPrincipale
    header
    Qt Code:
    1. #ifndef FENPRINCIPALE_H
    2. #define FENPRINCIPALE_H
    3. #include <QtGui>
    4. #include <QMainWindow>
    5. class FenPrincipale : public QMainWindow
    6. {
    7. public:
    8. FenPrincipale();
    9. private:
    10. };
    11. #endif // FENPRINCIPALE_H
    To copy to clipboard, switch view to plain text mode 
    main
    Qt Code:
    1. #include <QApplication>
    2. #include <QtGui>
    3. #include <QMainWindow>
    4. #include “FenPrincipale.h”
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8. FenPrincipale fenetre;
    9. fenetre.show();
    10. return app.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 
    .cpp
    Qt Code:
    1. #include “FenPrincipale.h”
    2. FenPrincipale::FenPrincipale()
    3. {
    4. }
    To copy to clipboard, switch view to plain text mode 
    it works fine for me, but later in the tuto he make a second project
    with the following main
    Qt Code:
    1. #include <QApplication>
    2. #include <QtGui>
    3. #include “FenPrincipale.h”
    4. FenPrincipale::FenPrincipale()
    5. {
    6. QVBoxLayout *layout = new QVBoxLayout;
    7. QDirModel *modele = new QDirModel;
    8. QTreeView *vue = new QTreeView;
    9. vue->setModel(modele);
    10. layout->addWidget(vue);
    11. setLayout(layout);
    12. }
    To copy to clipboard, switch view to plain text mode 
    i don't know what he did exactly he wasn't clear he just dropped that code but what i did is
    i made new project and paste FenPrincipale.h in the same folder with the new project but this is what i got
    C:\Qt\Qt5.0.1\5.0.1\mingw47_32\lib\libqtmaind.a(qt main_win.o):-1: In function `WinMain@16’:
    Q:\qt5_workdir\w\s\qtbase\src\winmain\qtmain_win.c pp:131: erreur : undefined reference to `qMain(int, char**)’
    collect2.exe:-1: erreur : error: ld returned 1 exit status
    Last edited by wysota; 27th February 2013 at 10:41. Reason: missing [code] tags

Similar Threads

  1. Replies: 7
    Last Post: 1st March 2011, 23:02
  2. qt creator create class problem
    By foxhengxing in forum Qt Programming
    Replies: 2
    Last Post: 30th June 2010, 16:32
  3. Create Own Signal send to different class
    By arpspatel in forum Qt Programming
    Replies: 0
    Last Post: 5th April 2010, 23:46
  4. class and event create
    By electronicboy in forum Qt Programming
    Replies: 2
    Last Post: 1st November 2009, 23:07
  5. Replies: 0
    Last Post: 9th March 2009, 03: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
  •  
Qt is a trademark of The Qt Company.