Results 1 to 7 of 7

Thread: New to QT

  1. #1
    Join Date
    Mar 2009
    Posts
    5

    Default New to QT

    I'm just trying to run the program, but I get this errror with respect to the class:

    :-1: error: collect2: ld returned 1 exit status

    I only get this error when I do T : public QObject
    (Adding QObject)

    Help would be appreciated! Thanks

    Qt Code:
    1. #ifndef T_H
    2. #define T_H
    3.  
    4. #include <QString>
    5. #include <QObject>
    6.  
    7. class T : public QObject
    8. {
    9. public:
    10. T() {}
    11. };
    12.  
    13. #endif // T_H
    To copy to clipboard, switch view to plain text mode 



    Qt Code:
    1. #include <QtCore/QCoreApplication>
    2. #include <QtDebug>
    3.  
    4.  
    5. #include <QString>
    6.  
    7. #include "T.h"
    8.  
    9.  
    10.  
    11. int main(int argc, char *argv[])
    12. {
    13. QCoreApplication aa(argc, argv);
    14.  
    15. T ok();
    16.  
    17.  
    18.  
    19. qDebug() << "ok";
    20.  
    21. return aa.exec();
    22. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by intek; 6th March 2009 at 00:16.

  2. #2
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: New to QT

    Do you have any experience with c++? I will try to help you out. First, what do you think "T ok();" is doing?

    Edit: Nevermind, I see what you are trying to do now. The name of your class and variable threw me off. I will look at it more when I get a chance, if no one else can help you out.
    Last edited by JimDaniel; 6th March 2009 at 01:23.

  3. #3
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: New to QT

    i used ur classes and it works..although u are making a very newbie mistake of not adding a Q_OBJECT macro in the header...but it shouldn't give that error..the problem must be that u must have run application once and not stopped it...cuz u dont have any window, there is no way of killing the application other than manually stopping it or killing the operation from task manager if u r using windows or kill command in unix..thus when u'll run it second time or later, it willl give this error. make sure the application isnt already running

  4. #4
    Join Date
    Mar 2009
    Posts
    5

    Default Re: New to QT

    Quote Originally Posted by talk2amulya View Post
    i used ur classes and it works..although u are making a very newbie mistake of not adding a Q_OBJECT macro in the header...but it shouldn't give that error..the problem must be that u must have run application once and not stopped it...cuz u dont have any window, there is no way of killing the application other than manually stopping it or killing the operation from task manager if u r using windows or kill command in unix..thus when u'll run it second time or later, it willl give this error. make sure the application isnt already running
    Mmm... I'm guessing what you explained was the problem because it works now.

    Thanks

    Edit:
    #include <QWidget> => QWidget: No such file or directory

    NOW WHAT? haha =P
    Last edited by intek; 6th March 2009 at 04:55.

  5. #5
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: New to QT

    isnt QtCore included in your project?

  6. #6
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: New to QT

    Qt Code:
    1. T ok();
    To copy to clipboard, switch view to plain text mode 

    I think this is a declaration of a function named ok and taking no parameters and returning value of type T.

    If you have QWidget not found, check if you are using Qt Gui module. It should be included by default but you may have something like :
    Qt Code:
    1. QT -= gui
    To copy to clipboard, switch view to plain text mode 
    in your .pro file. If there is such line, just remove it and qmake and make again.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  7. #7
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: New to QT

    1. How did you compile this project?
    2. Show us your .pro file.
    I'm a rebel in the S.D.G.

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.