Congratulations to our 2022 Qt Champions!

Access MainWindow controls from callback function

  • 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?

  • Lifetime Qt Champion

    @column You can use a singleton for this:

    class CallbackHandler: public QObject
        void someSignal(int);
        static CallbackHandler* instance() {
            static CallbackHandler* i = new CallbackHandler();
            return i;
        void doSomething(int value) { emit someSignal(value); }
    void cb(int value)

  • Lifetime Qt Champion


    What is the signature of that callback ?

Log in to reply