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. generalize a c++ method

generalize a c++ method

Scheduled Pinned Locked Moved Solved General and Desktop
34 Posts 5 Posters 6.7k 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.
  • mrjjM mrjj

    Hi
    Just to be sure i understand.
    You think it needs to be static to be used as a parameter
    OR
    you required it to be a plain c function pointer for the OPC UA to be able to use it later ?
    (since you have a

    You can use a class member as a parameter
    https://www.quantstart.com/articles/Function-Objects-Functors-in-C-Part-1
    https://isocpp.org/wiki/faq/pointers-to-members

    However, the instance having the function should stay alive then and not sure if you want that.

    ODБOïO Offline
    ODБOïO Offline
    ODБOï
    wrote on last edited by
    #3

    hi ! thanks for the answer
    @mrjj said in generalize a c++ method:

    You think it needs to be static to be used as a parameter

    yes, I thought that to be able to pass a function A to another function B, A must be static.

    thanks for the links i will update the solution here if i can

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #4

      Not sure what the links above cover, but std::bind can bind the instance of the object as the first parameter while leaving other parameters open in the resulting functor.

      C++ is a perfectly valid school of magic.

      ODБOïO 1 Reply Last reply
      3
      • fcarneyF fcarney

        Not sure what the links above cover, but std::bind can bind the instance of the object as the first parameter while leaving other parameters open in the resulting functor.

        ODБOïO Offline
        ODБOïO Offline
        ODБOï
        wrote on last edited by
        #5

        hi,
        @fcarney thx , i'm trying to understand how to use std::bind here (i have never used it)
        @mrjj the articles are very interesting but i am not able to find the solution that fits my need..

        please let me show you better my situation, so you can maybe suggest one solution

        class UaClient : public QObject
        {
            Q_OBJECT
        
        public:
        // CREATES A SUBSCRIPTION, TAKES A METHOD (theUpdateHandler)  THAT WILL BE CALLED LATER
        void uaSub(QScopedPointer<QOpcUaNode> &node, QString nodeId, void (*theUpdateHandler)(QOpcUa::NodeAttribute, const QVariant &)) {
        
            node.reset(m_client->node(nodeId));
            node->enableMonitoring(QOpcUa::NodeAttribute::Value, QOpcUaMonitoringParameters(200));
            QObject::connect(node.data(),&QOpcUaNode::attributeUpdated,[=](QOpcUa::NodeAttribute attr,const QVariant &value){
                theUpdateHandler(attr,value);
            });
        
        }
        
        private :
        // UPDATE HANDLER , HAS TO ACCESS MEMBER VARIABLES, HAS TO BE PASSED TO uaSub()
         static void nIndexUpdated(QOpcUa::NodeAttribute attr, const QVariant &value){  // m_someMember = value.toString(); 
                 return;
             }
        
        QString m_someMember;
        };
        
        ...
        // use the function to create subscriptions and pass the handler functions for every subscription
        uaSub(nIndexNode,"ns=4;s=MAIN.nIndex",*nIndexUpdated); 
        uaSub(nIndexNode,"ns=4;s=MAIN.nIndex",*speedValueUpdated); 
        uaSub(nIndexNode,"ns=4;s=MAIN.nIndex",*xxxUpdated); 
        
        

        this will work but handler methods (ex : nIndexUpdated ) can't access member variables because they are static.

        If i don't mark it static then I have an error in the uaSub method

        error  : reference to non-static member function must be called
        invalid use of memeber 'void UaClient::nIndexUpdated(QOpcUa::NodeAttribute,const QVariant&)' (did you forget the '&'  ? )
        

        So i still can't figure out how to pass a method to another method (when they both declared in the same class, and they are not static)

        jsulmJ 1 Reply Last reply
        0
        • ODБOïO ODБOï

          hi,
          @fcarney thx , i'm trying to understand how to use std::bind here (i have never used it)
          @mrjj the articles are very interesting but i am not able to find the solution that fits my need..

          please let me show you better my situation, so you can maybe suggest one solution

          class UaClient : public QObject
          {
              Q_OBJECT
          
          public:
          // CREATES A SUBSCRIPTION, TAKES A METHOD (theUpdateHandler)  THAT WILL BE CALLED LATER
          void uaSub(QScopedPointer<QOpcUaNode> &node, QString nodeId, void (*theUpdateHandler)(QOpcUa::NodeAttribute, const QVariant &)) {
          
              node.reset(m_client->node(nodeId));
              node->enableMonitoring(QOpcUa::NodeAttribute::Value, QOpcUaMonitoringParameters(200));
              QObject::connect(node.data(),&QOpcUaNode::attributeUpdated,[=](QOpcUa::NodeAttribute attr,const QVariant &value){
                  theUpdateHandler(attr,value);
              });
          
          }
          
          private :
          // UPDATE HANDLER , HAS TO ACCESS MEMBER VARIABLES, HAS TO BE PASSED TO uaSub()
           static void nIndexUpdated(QOpcUa::NodeAttribute attr, const QVariant &value){  // m_someMember = value.toString(); 
                   return;
               }
          
          QString m_someMember;
          };
          
          ...
          // use the function to create subscriptions and pass the handler functions for every subscription
          uaSub(nIndexNode,"ns=4;s=MAIN.nIndex",*nIndexUpdated); 
          uaSub(nIndexNode,"ns=4;s=MAIN.nIndex",*speedValueUpdated); 
          uaSub(nIndexNode,"ns=4;s=MAIN.nIndex",*xxxUpdated); 
          
          

          this will work but handler methods (ex : nIndexUpdated ) can't access member variables because they are static.

          If i don't mark it static then I have an error in the uaSub method

          error  : reference to non-static member function must be called
          invalid use of memeber 'void UaClient::nIndexUpdated(QOpcUa::NodeAttribute,const QVariant&)' (did you forget the '&'  ? )
          

          So i still can't figure out how to pass a method to another method (when they both declared in the same class, and they are not static)

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #6

          @LeLev said in generalize a c++ method:

          when they both declared in the same class

          If they are both in the same class then why do you want to mess around with pointers? I would rather use an enum to specify what I want to execute. You only have 3 different methods in your example, so using pointers will not give you any performance advantages.

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

          ODБOïO 1 Reply Last reply
          1
          • jsulmJ jsulm

            @LeLev said in generalize a c++ method:

            when they both declared in the same class

            If they are both in the same class then why do you want to mess around with pointers? I would rather use an enum to specify what I want to execute. You only have 3 different methods in your example, so using pointers will not give you any performance advantages.

            ODБOïO Offline
            ODБOïO Offline
            ODБOï
            wrote on last edited by ODБOï
            #7

            @mrjj do you mean like this ? this looks good except i will have a huge switch

              enum class UpdateHandlers: qint32{
                    NINDEX = 0, 
                    SPEED = 1,  
                    XXX = 2
                };
            
            void MachineBackend::uaSub1(QScopedPointer<QOpcUaNode> &node, QString nodeId, UpdateHandlers theHandler){
                
                node.reset(m_client->node(nodeId));
                node->enableMonitoring(QOpcUa::NodeAttribute::Value, QOpcUaMonitoringParameters(200));
                QObject::connect(node.data(),&QOpcUaNode::attributeUpdated,[=](QOpcUa::NodeAttribute attr,const QVariant &value){
                          
                    switch (theHandler) {
                    
                    case UpdateHandlers::NINDEX :   nIndexUpdated(attr,value);break;
                    case UpdateHandlers::SPEED  :   nSpeeedUpdated(attr,value);break;
                    case UpdateHandlers::XXX    :   xxxUpdated(attr,value);break;
                    default: break;            
                    }              
                });  
                
                return;    
            }
            
            
            
            
            ODБOïO jsulmJ 2 Replies Last reply
            0
            • ODБOïO ODБOï

              @mrjj do you mean like this ? this looks good except i will have a huge switch

                enum class UpdateHandlers: qint32{
                      NINDEX = 0, 
                      SPEED = 1,  
                      XXX = 2
                  };
              
              void MachineBackend::uaSub1(QScopedPointer<QOpcUaNode> &node, QString nodeId, UpdateHandlers theHandler){
                  
                  node.reset(m_client->node(nodeId));
                  node->enableMonitoring(QOpcUa::NodeAttribute::Value, QOpcUaMonitoringParameters(200));
                  QObject::connect(node.data(),&QOpcUaNode::attributeUpdated,[=](QOpcUa::NodeAttribute attr,const QVariant &value){
                            
                      switch (theHandler) {
                      
                      case UpdateHandlers::NINDEX :   nIndexUpdated(attr,value);break;
                      case UpdateHandlers::SPEED  :   nSpeeedUpdated(attr,value);break;
                      case UpdateHandlers::XXX    :   xxxUpdated(attr,value);break;
                      default: break;            
                      }              
                  });  
                  
                  return;    
              }
              
              
              
              
              ODБOïO Offline
              ODБOïO Offline
              ODБOï
              wrote on last edited by ODБOï
              #8

              edit @mrjj sorry not for you

              @jsulm
              do you mean this ?

               enum  UpdateHandlers : qint32{
                      NINDEX, 
                      SPEED, 
                      XXX
                  };
              
              
              void MachineBackend::uaSub1(QScopedPointer<QOpcUaNode> &node, QString nodeId, UpdateHandlers theHandler){
                  
                  node.reset(m_client->node(nodeId));
                  node->enableMonitoring(QOpcUa::NodeAttribute::Value, QOpcUaMonitoringParameters(200));
                  QObject::connect(node.data(),&QOpcUaNode::attributeUpdated,[=](QOpcUa::NodeAttribute attr,const QVariant &value){
                     
                      
                      switch (theHandler) {
                      
                      case UpdateHandlers::NINDEX :   nIndexUpdated(attr,value);break;
                      case UpdateHandlers::SPEED  :   nSpeeedUpdated(attr,value);break;
                      case UpdateHandlers::XXX    :   xxxUpdated(attr,value);break;
                      default: break;
                          
                      }
                      
                      
                  });
                  
                  
                  return;
                  
              }
              
              1 Reply Last reply
              0
              • ODБOïO ODБOï

                @mrjj do you mean like this ? this looks good except i will have a huge switch

                  enum class UpdateHandlers: qint32{
                        NINDEX = 0, 
                        SPEED = 1,  
                        XXX = 2
                    };
                
                void MachineBackend::uaSub1(QScopedPointer<QOpcUaNode> &node, QString nodeId, UpdateHandlers theHandler){
                    
                    node.reset(m_client->node(nodeId));
                    node->enableMonitoring(QOpcUa::NodeAttribute::Value, QOpcUaMonitoringParameters(200));
                    QObject::connect(node.data(),&QOpcUaNode::attributeUpdated,[=](QOpcUa::NodeAttribute attr,const QVariant &value){
                              
                        switch (theHandler) {
                        
                        case UpdateHandlers::NINDEX :   nIndexUpdated(attr,value);break;
                        case UpdateHandlers::SPEED  :   nSpeeedUpdated(attr,value);break;
                        case UpdateHandlers::XXX    :   xxxUpdated(attr,value);break;
                        default: break;            
                        }              
                    });  
                    
                    return;    
                }
                
                
                
                
                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #9

                @LeLev See https://stackoverflow.com/questions/14315346/function-pointer-of-a-non-static-member-function-of-a-class
                With non-static methods you need an instance of the class to call the method:

                typedef void (T::*MethodPtr) ();
                MethodPtr method = &T::MethodA;
                T *obj = new T();
                obj->*method();
                

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

                ODБOïO 1 Reply Last reply
                1
                • jsulmJ jsulm

                  @LeLev See https://stackoverflow.com/questions/14315346/function-pointer-of-a-non-static-member-function-of-a-class
                  With non-static methods you need an instance of the class to call the method:

                  typedef void (T::*MethodPtr) ();
                  MethodPtr method = &T::MethodA;
                  T *obj = new T();
                  obj->*method();
                  
                  ODБOïO Offline
                  ODБOïO Offline
                  ODБOï
                  wrote on last edited by
                  #10

                  @jsulm i think i can not use this last solution, because there is only one instance of this class. it is instantiated in the main.cpp and putted as contextProperty, it is never destroyed and has same life time as my application. I can not create another object of this class

                  J.HilkJ jsulmJ 2 Replies Last reply
                  0
                  • ODБOïO ODБOï

                    @jsulm i think i can not use this last solution, because there is only one instance of this class. it is instantiated in the main.cpp and putted as contextProperty, it is never destroyed and has same life time as my application. I can not create another object of this class

                    J.HilkJ Offline
                    J.HilkJ Offline
                    J.Hilk
                    Moderators
                    wrote on last edited by
                    #11

                    @LeLev said in generalize a c++ method:

                    @jsulm i think i can not use this last solution, because there is only one instance of this class. it is instantiated in the main.cpp and putted as contextProperty, it is never destroyed and has same life time as my application. I can not create another object of this class

                    ok, when this - in essence - is a singleton, why don't you make the member variable then also static?


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    ODБOïO 1 Reply Last reply
                    1
                    • ODБOïO Offline
                      ODБOïO Offline
                      ODБOï
                      wrote on last edited by
                      #12

                      because i'm JS guy ... i 'm learning Qt/cpp only for 2 years now.
                      let me try it

                      1 Reply Last reply
                      0
                      • J.HilkJ J.Hilk

                        @LeLev said in generalize a c++ method:

                        @jsulm i think i can not use this last solution, because there is only one instance of this class. it is instantiated in the main.cpp and putted as contextProperty, it is never destroyed and has same life time as my application. I can not create another object of this class

                        ok, when this - in essence - is a singleton, why don't you make the member variable then also static?

                        ODБOïO Offline
                        ODБOïO Offline
                        ODБOï
                        wrote on last edited by ODБOï
                        #13

                        @J-Hilk said in generalize a c++ method:

                        why don't you make the member variable then also static?

                        i have one member variable per subscription,
                        each member variable has a Q_PROPERTY corresponding to it, so i can use the variable value from QML.

                        is it possible do define Q_PROPERTIES for a static member variable ?

                        Im trying but getting errors :
                        moc_machinebackend.cpp:-1: erreur : undefined reference to `MachineBackend::m_url'

                         Q_PROPERTY(QString url READ url WRITE setUrl NOTIFY urlChanged)
                        
                        public:
                         QString url()const{
                               return MachineBackend::m_url; 
                            }
                            void setUrl(const QString nUrl){
                                if(MachineBackend::m_url==nUrl)return;
                                MachineBackend::m_url = nUrl;
                                emit urlChanged(nUrl);
                            }
                        
                        private : 
                        static QString m_url;
                        
                        signals:
                        void urlChanged(QString url);
                        
                        1 Reply Last reply
                        0
                        • ODБOïO ODБOï

                          @jsulm i think i can not use this last solution, because there is only one instance of this class. it is instantiated in the main.cpp and putted as contextProperty, it is never destroyed and has same life time as my application. I can not create another object of this class

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by jsulm
                          #14

                          @LeLev said in generalize a c++ method:

                          i think i can not use this last solution

                          Sure you can: you pass the pointer to second method when you call the first method, right? And since both methods are not static you call the first method already on an instance (which is "this" inside the method):

                          this->*method(); // method is the pointer to the other method
                          

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

                          ODБOïO 1 Reply Last reply
                          1
                          • jsulmJ jsulm

                            @LeLev said in generalize a c++ method:

                            i think i can not use this last solution

                            Sure you can: you pass the pointer to second method when you call the first method, right? And since both methods are not static you call the first method already on an instance (which is "this" inside the method):

                            this->*method(); // method is the pointer to the other method
                            
                            ODБOïO Offline
                            ODБOïO Offline
                            ODБOï
                            wrote on last edited by ODБOï
                            #15

                            @jsulm said in generalize a c++ method:

                            : you pass the pointer to second method when you call the first method, right?

                            Yes, but it only works if the
                            2nd method is static !

                            //first 
                            void uaSub(QScopedPointer<QOpcUaNode> &node, QString nodeId , void (*theUpdateHandler)(QOpcUa::NodeAttribute attr,const QVariant &value)){...}
                            // 2nd
                            static void nIndexUpdated(QOpcUa::NodeAttribute attr, const QVariant &value){...}
                            
                            
                            uaSub(nIndexNode,"ns=4;s=MAIN.nIndex",*nIndexUpdated){...}
                            
                            //Here **nIndexUpdated** must be static !  no ?
                            

                            if it is not static i get :
                            reference to non-static member function must be called error

                            jsulmJ 1 Reply Last reply
                            0
                            • ODБOïO ODБOï

                              @jsulm said in generalize a c++ method:

                              : you pass the pointer to second method when you call the first method, right?

                              Yes, but it only works if the
                              2nd method is static !

                              //first 
                              void uaSub(QScopedPointer<QOpcUaNode> &node, QString nodeId , void (*theUpdateHandler)(QOpcUa::NodeAttribute attr,const QVariant &value)){...}
                              // 2nd
                              static void nIndexUpdated(QOpcUa::NodeAttribute attr, const QVariant &value){...}
                              
                              
                              uaSub(nIndexNode,"ns=4;s=MAIN.nIndex",*nIndexUpdated){...}
                              
                              //Here **nIndexUpdated** must be static !  no ?
                              

                              if it is not static i get :
                              reference to non-static member function must be called error

                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by
                              #16

                              @LeLev Please take a closer look at the snippet I provided before:

                              typedef void (T::*MethodPtr) ();
                              MethodPtr method = &T::MethodA;
                              T *obj = new T();
                              obj->*method();
                              

                              Your syntax is not even correct as you have to use & to get a pointer not *
                              So in your case something like

                              class A
                              {
                                  typedef void (A::*MethodPtr) ();
                                  void nIndexUpdated() {}
                                  void uaSub(..., MethodPtr ptr) {
                                      this->*ptr();
                                  }
                              
                                  // Somewhere inside class A you call uaSub
                                  uaSub(/*params*/, &A::nIndexUpdated);
                              }
                              

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

                              ODБOïO 1 Reply Last reply
                              1
                              • jsulmJ jsulm

                                @LeLev Please take a closer look at the snippet I provided before:

                                typedef void (T::*MethodPtr) ();
                                MethodPtr method = &T::MethodA;
                                T *obj = new T();
                                obj->*method();
                                

                                Your syntax is not even correct as you have to use & to get a pointer not *
                                So in your case something like

                                class A
                                {
                                    typedef void (A::*MethodPtr) ();
                                    void nIndexUpdated() {}
                                    void uaSub(..., MethodPtr ptr) {
                                        this->*ptr();
                                    }
                                
                                    // Somewhere inside class A you call uaSub
                                    uaSub(/*params*/, &A::nIndexUpdated);
                                }
                                
                                ODБOïO Offline
                                ODБOïO Offline
                                ODБOï
                                wrote on last edited by ODБOï
                                #17

                                @jsulm
                                thank you so much for the help you provide.
                                Unfortunately i'm so bad, i can't make this work

                                class MachineBackend : public QObject
                                {
                                    typedef void (MachineBackend::*MethodPtr) ();
                                    Q_OBJECT
                                
                                void nIndexUpdated(QOpcUa::NodeAttribute attr, const QVariant &value){...}
                                
                                void uaSub2(QScopedPointer<QOpcUaNode>&node, QString nodeId, MethodPtr updateHandlerPtr){
                                       
                                       this->*updateHandlerPtr(); // < error here 
                                
                                    }
                                };
                                

                                called object type 'MachineBackend ::MethodPtr' (aka 'void (MachineBackend ::*)()' ) is not a function or function pointer

                                jsulmJ 1 Reply Last reply
                                0
                                • ODБOïO ODБOï

                                  @jsulm
                                  thank you so much for the help you provide.
                                  Unfortunately i'm so bad, i can't make this work

                                  class MachineBackend : public QObject
                                  {
                                      typedef void (MachineBackend::*MethodPtr) ();
                                      Q_OBJECT
                                  
                                  void nIndexUpdated(QOpcUa::NodeAttribute attr, const QVariant &value){...}
                                  
                                  void uaSub2(QScopedPointer<QOpcUaNode>&node, QString nodeId, MethodPtr updateHandlerPtr){
                                         
                                         this->*updateHandlerPtr(); // < error here 
                                  
                                      }
                                  };
                                  

                                  called object type 'MachineBackend ::MethodPtr' (aka 'void (MachineBackend ::*)()' ) is not a function or function pointer

                                  jsulmJ Offline
                                  jsulmJ Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #18

                                  @LeLev Try

                                  this->updateHandlerPtr();
                                  

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

                                  ODБOïO 1 Reply Last reply
                                  1
                                  • jsulmJ jsulm

                                    @LeLev Try

                                    this->updateHandlerPtr();
                                    
                                    ODБOïO Offline
                                    ODБOïO Offline
                                    ODБOï
                                    wrote on last edited by
                                    #19

                                    @jsulm said in generalize a c++ method:

                                    this->updateHandlerPtr();

                                    yes i did also, in that case error is :

                                    no member named 'updateHandlerPtr' in 'MachineBackend '
                                    which is true

                                    jsulmJ 1 Reply Last reply
                                    0
                                    • ODБOïO ODБOï

                                      @jsulm said in generalize a c++ method:

                                      this->updateHandlerPtr();

                                      yes i did also, in that case error is :

                                      no member named 'updateHandlerPtr' in 'MachineBackend '
                                      which is true

                                      jsulmJ Offline
                                      jsulmJ Offline
                                      jsulm
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #20

                                      @LeLev This should compile:

                                      (this->*updateHandlerPtr)();
                                      

                                      Method pointers are a mess :-)

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

                                      1 Reply Last reply
                                      2
                                      • ODБOïO Offline
                                        ODБOïO Offline
                                        ODБOï
                                        wrote on last edited by
                                        #21

                                        yes now it doas. awesome ! thank you so much!

                                        class MachineBackend : public QObject
                                        {
                                            typedef void (MachineBackend::*MethodPtr) ();
                                            Q_OBJECT
                                        
                                        void nIndexUpdated(QOpcUa::NodeAttribute attr, const QVariant &value){...}
                                        
                                        void uaSub2(QScopedPointer<QOpcUaNode>&node, QString nodeId, MethodPtr updateHandlerPtr){
                                               
                                               (this->*updateHandlerPtr)();
                                        
                                            }
                                        };
                                        
                                        
                                        
                                        

                                        there is still an issue in the usSub() call

                                        //  Somewhere inside class
                                          uaSub2(nIndexNode,"ns=4;s=MAIN.nIndex", MachineBackend::nIndexUpdated);  // << error
                                        //
                                        

                                        error : reference to non-static member function must be called

                                        im trying every possible syntax right now ...

                                        jsulmJ 2 Replies Last reply
                                        0
                                        • ODБOïO ODБOï

                                          yes now it doas. awesome ! thank you so much!

                                          class MachineBackend : public QObject
                                          {
                                              typedef void (MachineBackend::*MethodPtr) ();
                                              Q_OBJECT
                                          
                                          void nIndexUpdated(QOpcUa::NodeAttribute attr, const QVariant &value){...}
                                          
                                          void uaSub2(QScopedPointer<QOpcUaNode>&node, QString nodeId, MethodPtr updateHandlerPtr){
                                                 
                                                 (this->*updateHandlerPtr)();
                                          
                                              }
                                          };
                                          
                                          
                                          
                                          

                                          there is still an issue in the usSub() call

                                          //  Somewhere inside class
                                            uaSub2(nIndexNode,"ns=4;s=MAIN.nIndex", MachineBackend::nIndexUpdated);  // << error
                                          //
                                          

                                          error : reference to non-static member function must be called

                                          im trying every possible syntax right now ...

                                          jsulmJ Offline
                                          jsulmJ Offline
                                          jsulm
                                          Lifetime Qt Champion
                                          wrote on last edited by
                                          #22

                                          @LeLev said in generalize a c++ method:

                                          uaSub2(nIndexNode,"ns=4;s=MAIN.nIndex", MachineBackend::nIndexUpdated);

                                          uaSub2(nIndexNode,"ns=4;s=MAIN.nIndex", &MachineBackend::nIndexUpdated);
                                          

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

                                          ODБOïO 1 Reply Last reply
                                          1

                                          • Login

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