Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Access MainWindow controls from callback function

Access MainWindow controls from callback function

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 586 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    column
    wrote on 4 May 2018, 09:07 last edited by
    #1

    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?

    J 1 Reply Last reply 4 May 2018, 10:56
    0
    • C column
      4 May 2018, 09:07

      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?

      J Online
      J Online
      jsulm
      Lifetime Qt Champion
      wrote on 4 May 2018, 10:56 last edited by
      #2

      @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);
      }
      

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 4 May 2018, 21:17 last edited by
        #3

        Hi,

        What is the signature of that callback ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0

        1/3

        4 May 2018, 09:07

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved