Access MainWindow controls from callback function
Unsolved
General and Desktop
-
Hello,
What is the best way to access
MainWindow
controls from callback function?For example I have callback function that was initialized by passing to .so library function parameter. *.so library is going to update progress status by using it.
cb(int value) { }
And I need to show value in text box of
tbCommandReturnMessage
. Can I somehow use signals and slots for this purpose? -
@column You can use a singleton for this:
class CallbackHandler: public QObject { signals: void someSignal(int); public: static CallbackHandler* instance() { static CallbackHandler* i = new CallbackHandler(); return i; } void doSomething(int value) { emit someSignal(value); } }; void cb(int value) { CallbackHandler::instance()->doSomething(value); }
-
Hi,
What is the signature of that callback ?