hi, im having a strange problem when trying to emit a signal from a thread.
thread.h:
#ifndef USBCOM_H
#define USBCOM_H
#include <QObject>
#include <QThread>
{
public:
UsbCom();
void run();
signals:
};
#endif // USBCOM_H
#ifndef USBCOM_H
#define USBCOM_H
#include <QObject>
#include <QThread>
class UsbCom : public QThread
{
public:
UsbCom();
void run();
signals:
void error(QString error);
};
#endif // USBCOM_H
To copy to clipboard, switch view to plain text mode
thread.cpp:
#include "usbcom.h"
#include <QtGui>
UsbCom::UsbCom()
{
}
void UsbCom::run()
{
emit error("error!");
}
#include "usbcom.h"
#include <QtGui>
UsbCom::UsbCom()
{
}
void UsbCom::run()
{
emit error("error!");
}
To copy to clipboard, switch view to plain text mode
now when trying to compile this program i am getting an undefined refference error from the compiler.
Running build steps for project Project...
Configuration unchanged, skipping QMake step.
Starting: /usr/bin/make -w
make: Entering directory `/home/sisco/Documents/School/Project 3/Project Software/Project'
g++ -c -m64 -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/home/sisco/qtsdk-2009.04/qt/mkspecs/linux-g++-64 -I. -I/home/sisco/qtsdk-2009.04/qt/include/QtCore -I/home/sisco/qtsdk-2009.04/qt/include/QtGui -I/home/sisco/qtsdk-2009.04/qt/include -I../../src -I../../src -Imoc -I. -o obj/project.o project.cpp
g++ -c -m64 -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/home/sisco/qtsdk-2009.04/qt/mkspecs/linux-g++-64 -I. -I/home/sisco/qtsdk-2009.04/qt/include/QtCore -I/home/sisco/qtsdk-2009.04/qt/include/QtGui -I/home/sisco/qtsdk-2009.04/qt/include -I../../src -I../../src -Imoc -I. -o obj/usbcom.o usbcom.cpp
g++ -m64 -Wl,-rpath,/home/sisco/qtsdk-2009.04/qt/lib -o ../../examples/bin/Project obj/main.o obj/project.o obj/savedialog.o obj/overwritedialog.o obj/tables.o obj/usbcom.o obj/moc_project.o obj/moc_savedialog.o obj/moc_overwritedialog.o obj/moc_tables.o obj/qrc_icons.o -L/home/sisco/qtsdk-2009.04/qt/lib -L../../lib -lqwt -lusb-1.0 -lQtGui -L/home/sisco/qtsdk-2009.04/qt/lib -L/usr/X11R6/lib64 -pthread -lfreetype -lgobject-2.0 -lSM -lICE -pthread -pthread -lXrender -lfontconfig -lXext -lX11 -lQtCore -lm -pthread -lgthread-2.0 -lrt -lglib-2.0 -ldl -lpthread
obj/usbcom.o: In function `UsbCom::run()':
/home
/sisco
/Documents
/School
/Project
3/Project Software
/Project
/usbcom.
cpp:10: undefined reference to `UsbCom
::error(QString)' collect2: ld returned 1 exit status
make: Leaving directory `/home/sisco/Documents/School/Project 3/Project Software/Project'
make: *** [../../examples/bin/Project] Error 1
Exited with code 2.
Error while building project Project
When executing build step 'Make'
Running build steps for project Project...
Configuration unchanged, skipping QMake step.
Starting: /usr/bin/make -w
make: Entering directory `/home/sisco/Documents/School/Project 3/Project Software/Project'
g++ -c -m64 -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/home/sisco/qtsdk-2009.04/qt/mkspecs/linux-g++-64 -I. -I/home/sisco/qtsdk-2009.04/qt/include/QtCore -I/home/sisco/qtsdk-2009.04/qt/include/QtGui -I/home/sisco/qtsdk-2009.04/qt/include -I../../src -I../../src -Imoc -I. -o obj/project.o project.cpp
g++ -c -m64 -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/home/sisco/qtsdk-2009.04/qt/mkspecs/linux-g++-64 -I. -I/home/sisco/qtsdk-2009.04/qt/include/QtCore -I/home/sisco/qtsdk-2009.04/qt/include/QtGui -I/home/sisco/qtsdk-2009.04/qt/include -I../../src -I../../src -Imoc -I. -o obj/usbcom.o usbcom.cpp
g++ -m64 -Wl,-rpath,/home/sisco/qtsdk-2009.04/qt/lib -o ../../examples/bin/Project obj/main.o obj/project.o obj/savedialog.o obj/overwritedialog.o obj/tables.o obj/usbcom.o obj/moc_project.o obj/moc_savedialog.o obj/moc_overwritedialog.o obj/moc_tables.o obj/qrc_icons.o -L/home/sisco/qtsdk-2009.04/qt/lib -L../../lib -lqwt -lusb-1.0 -lQtGui -L/home/sisco/qtsdk-2009.04/qt/lib -L/usr/X11R6/lib64 -pthread -lfreetype -lgobject-2.0 -lSM -lICE -pthread -pthread -lXrender -lfontconfig -lXext -lX11 -lQtCore -lm -pthread -lgthread-2.0 -lrt -lglib-2.0 -ldl -lpthread
obj/usbcom.o: In function `UsbCom::run()':
/home/sisco/Documents/School/Project 3/Project Software/Project/usbcom.cpp:10: undefined reference to `UsbCom::error(QString)'
collect2: ld returned 1 exit status
make: Leaving directory `/home/sisco/Documents/School/Project 3/Project Software/Project'
make: *** [../../examples/bin/Project] Error 1
Exited with code 2.
Error while building project Project
When executing build step 'Make'
To copy to clipboard, switch view to plain text mode
code used in my main class:
usbcom = new UsbCom();
usbcom->start();
usbcom = new UsbCom();
connect(usbcom, SIGNAL(error(QString)), SLOT(usbError(QString)));
usbcom->start();
To copy to clipboard, switch view to plain text mode
what am i doing wrong?
Bookmarks