Results 1 to 6 of 6

Thread: QMake issue

  1. #1
    Join Date
    Mar 2006
    Posts
    142
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    8
    Thanked 1 Time in 1 Post

    Default QMake issue

    I get an error at linking stage since I add a new class above my main() (undefined reference to `vtable for myHelp'). I have read that such an error may be due to the lack of a moc_ file and surprisingly Qmake does not generate a moc_ file for this file named main.cxx
    Any help?
    Qt Code:
    1. class myHelp : public QMessageBox
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. myHelp(QString text=QString());
    7. virtual ~myHelp() {};
    8.  
    9. public slots:
    10. int minimumWidth() const {return 800;};
    11. QSize minimumSize() const {return QSize(800, 800);};
    12. };
    13.  
    14. myHelp::myHelp(QString text)
    15. : QMessageBox(QMessageBox::NoIcon, QString::fromLocal8Bit("My message"), text, QMessageBox::Ok)
    16. {};
    17.  
    18. int main()
    19. ...
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QMake issue

    QMake only scans header files for Q_OBJECT macro. Either add an '#include "main.moc"' statement to your file (which explicitely tells qmake to invoke moc on the file) or move the class header containing the Q_OBJECT macro to a header file.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2006
    Posts
    142
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    8
    Thanked 1 Time in 1 Post

    Default Re: QMake issue

    Quote Originally Posted by wysota View Post
    QMake only scans header files for Q_OBJECT macro. Either add an '#include "main.moc"' statement to your file (which explicitely tells qmake to invoke moc on the file) or move the class header containing the Q_OBJECT macro to a header file.
    Hmmm, I do not understand. I declare the class with the Q_OBJECT macro in a file named "main.cxx" so which statement should I include and in which file please?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QMake issue

    #include "main.moc" after the class definition in main.cxx
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Mar 2006
    Posts
    142
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    8
    Thanked 1 Time in 1 Post

    Default Re: QMake issue

    Quote Originally Posted by wysota View Post
    #include "main.moc" after the class definition in main.cxx
    I get:

    main.cxx:33:19: error: main.moc: No such file or directory

    May be is it necessary to add some quotes to prevent the C++ preprocessor to process this line?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QMake issue

    No, you need to run qmake after adding the statement.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. The following user says thank you to wysota for this useful post:

    Caius Aérobus (20th October 2009)

Similar Threads

  1. qmake sux a lot
    By singermornings in forum Qt Programming
    Replies: 6
    Last Post: 29th January 2009, 08:33
  2. qmake issue with UIC
    By rickbsgu in forum Qt Programming
    Replies: 1
    Last Post: 7th February 2008, 01:07
  3. qt3 to qt4 - uic issue
    By hvengel in forum Qt Programming
    Replies: 10
    Last Post: 4th March 2007, 02:59
  4. Qt Cryptographic Architecture
    By vermarajeev in forum Qt Programming
    Replies: 6
    Last Post: 9th February 2007, 13:15
  5. Issue with QMake
    By jcr in forum Qt Programming
    Replies: 4
    Last Post: 13th March 2006, 23:31

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.