Waiting for qt signal in c++ function
-
Hi,
im search way to recive signal from qt object in c++fnx(){
QSharedPointer client; //pointer to qt object
client->doSomeWork(); //its emit done when finished.
...
next operations.
} -
@NewbieQTUser You can also connect a function:
void fnx() { client->doSomeWork(); QObject::connect(client, &ClientClass::done, &doStuff); } void doStuff() { // following operations }
-
Hi,
Why not connect that signal to a function that will continue the processing ?
-
void MyClass::fnx() { client->doSomeWork(); connect(client, &ClientClass::done, this, &MyClass::doStuff); } void MyClass::doStuff() { // following operations }
-
Im calling it from generic c++ app, i cant use connect syntax
-
@NewbieQTUser What do you mean you can't? If
client
emits a signal it means it's a QObject. If you're accessing QObjects you can access connect. Qt is generic C++, so could you explain what's your problem exactly? -
connect is a static method so you still can.
Otherwise, you can pass that method to your doSomeWork function so that it can be connected to by your class.
-
Its function only, but i will try pass it to doSomeWork, thanks for help :)
-
@NewbieQTUser You can also connect a function:
void fnx() { client->doSomeWork(); QObject::connect(client, &ClientClass::done, &doStuff); } void doStuff() { // following operations }
-
@Chris-Kawa said in Waiting for qt signal in c++ function:
@NewbieQTUser You can also connect a function:
void fnx() { client->doSomeWork(); QObject::connect(client, &ClientClass::done, &doStuff); } void doStuff() { // following operations }
Also thx, looks like a good solution
-