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
Forum Updated to NodeBB v4.3 + New Features

Access MainWindow controls from callback function

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 627 Views 2 Watching
  • 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 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?

    jsulmJ 1 Reply Last reply
    0
    • C column

      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?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on 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
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on 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

        • Login

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