I know it's not threadsafe to call a function of another thread in Mainthread. Is it allowed to call a signal form another thread without any problems? Lets say this code is in MainWindow:
MainWindow.cpp
thread->moveTOThread(obj);
emit obj->Signal();
MainWindow.cpp
thread->moveTOThread(obj);
emit obj->Signal();
To copy to clipboard, switch view to plain text mode
or is this the way to go:
Obj.h
signals:
void testSignal();
public slots:
void Func();
MainWindow.h
void testSignal();
MainWindow.cpp
thread->moveTOThread(obj);
connect(this,SIGNAL(testSignal()),obj,SIGNAL(testSignal()));
emit testSignal();
Obj.cpp
connect(this,SIGNAL(testSignal()),this,SLOT(Func()));
Obj.h
signals:
void testSignal();
public slots:
void Func();
MainWindow.h
void testSignal();
MainWindow.cpp
thread->moveTOThread(obj);
connect(this,SIGNAL(testSignal()),obj,SIGNAL(testSignal()));
emit testSignal();
Obj.cpp
connect(this,SIGNAL(testSignal()),this,SLOT(Func()));
To copy to clipboard, switch view to plain text mode
thank you
Bookmarks