PDA

View Full Version : New to QT



intek
6th March 2009, 00:54
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



#ifndef T_H
#define T_H

#include <QString>
#include <QObject>

class T : public QObject
{
public:
T() {}
};

#endif // T_H






#include <QtCore/QCoreApplication>
#include <QtDebug>


#include <QString>

#include "T.h"



int main(int argc, char *argv[])
{
QCoreApplication aa(argc, argv);

T ok();



qDebug() << "ok";

return aa.exec();
}

JimDaniel
6th March 2009, 02:18
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.

talk2amulya
6th March 2009, 03:51
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

intek
6th March 2009, 05:32
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

talk2amulya
6th March 2009, 08:00
isnt QtCore included in your project?

faldzip
6th March 2009, 11:25
T ok();


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 -= gui

in your .pro file. If there is such line, just remove it and qmake and make again.

lyuts
14th March 2009, 13:22
1. How did you compile this project?
2. Show us your .pro file.