Why Qt hangs?
-
-
[quote author="dwsld" date="1363979507"]Well this happens only in qt.I mean when I push the button for the socket the program hangs.[/quote]
I think the codes are NOT Qt-specific (I think they are M$'s API). Why not use QThread instead? It might be a problem with MOC.
-
Could you please define 'hangs'?
As I read it, you GUI freezes because the program is waiting on the accept call to return.
-
Check the documentation about QThread: "Click":http://qt-project.org/doc/qt-4.8/qthread.html
Goodluck! -
I have some error :
mainwindow.obj:-1: error: LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall Worker::metaObject(void)const " (?metaObject@Worker@@UBEPBUQMetaObject@@XZ).mainwindow.obj:-1: error: LNK2001: unresolved external symbol "public: virtual void * __thiscall Worker::qt_metacast(char const *)" (?qt_metacast@Worker@@UAEPAXPBD@Z)
mainwindow.obj:-1: error: LNK2001: unresolved external symbol "public: virtual int __thiscall Worker::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@Worker@@UAEHW4Call@QMetaObject@@HPAPAX@Z)
@
class Worker : public QObject
{
Q_OBJECTpublic slots:
void doWork() {
/* ... */
}
};.....
QThread *thread = new QThread;
Worker *worker = new Worker;
worker->moveToThread(thread);
thread->start();@ -
Few things you could try / check:
- clean and rebuild
- Check in the implementation file if the classname is in front of the methods (Worker::doWork() etc)
- moc the class (run QMake)