跳到內容
  • 版面
  • 最新
  • 標籤
  • 熱門
  • 使用者
  • 群組
  • 搜尋
  • Get Qt Extensions
  • Unsolved
Collapse
品牌標誌
  1. 首頁
  2. Qt Development
  3. Mobile and Embedded
  4. Nested class in Qt5
Forum Updated to NodeBB v4.3 + New Features

Nested class in Qt5

已排程 已置頂 已鎖定 已移動 Unsolved Mobile and Embedded
26 貼文 5 Posters 5.3k 瀏覽 3 Watching
  • 從舊到新
  • 從新到舊
  • 最多點贊
回覆
  • 在新貼文中回覆
登入後回覆
此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
  • J 離線
    J 離線
    Juancinho_cardecan
    寫於 最後由 編輯
    #1

    Hello everybody ,

    I am using Qt5.14.1 with the MinGW 32-bit compiler. I am trying to nest one classe brightness in the same outer class rgbLed and call variables from brightness class and manage those variable inside a function from the class rgbLed .

    rgbLed and brightness, both are QObject type class. I would like to call variables from brightness into rgbLed methods.

    I was trying to use nested classes but I had problems with Meta Object Compiler, Is there any way to fix this issue?

    So, I write the code as follow:

    #include <QObject>
    #include <QDebug>
    #include <QtQml>
    #include <iostream>
    
    using namespace std;
    
    class brightness : public QObject
    {
        Q_OBJECT
    public:
        explicit brightness(QObject *parent = 0);
    
    public slots:
        void brightnessText(const QString& in);
    private:
        bool flag = 0;
    };
    
    class rgbLed : public QObject
    {
        Q_OBJECT
        Q_PROPERTY(int bright READ bright WRITE setBright NOTIFY brightChanged)
    public:
        explicit rgbLed(QObject *parent = nullptr);
        int regresion_red(int red);
        int regresion_green(int green);
        int regresion_blue(int blue);
    
        Q_INVOKABLE int bright();
        Q_INVOKABLE int setBright(int x);
        Q_INVOKABLE void add(rgbLed *x);
    
    
        int r;
        int g;
        int b;
        int r2;
        int g2;
        int b2;
        int brightValue;
        int myBrightness;
        QStringList list;
        QString my_in;
    
        int red = 0;
        int green = 0;
        int blue = 0;
        int pos = 0 ;
        bool flag = 0;
        int x;
    
    signals:
        void brightChanged(int x);
    
    public slots:
        void rgbRecive(const QString &in);
    };
    
    #endif // RGBLED_H
    
    sierdzioS 1 條回覆 最後回覆
    0
    • J Juancinho_cardecan

      Hello everybody ,

      I am using Qt5.14.1 with the MinGW 32-bit compiler. I am trying to nest one classe brightness in the same outer class rgbLed and call variables from brightness class and manage those variable inside a function from the class rgbLed .

      rgbLed and brightness, both are QObject type class. I would like to call variables from brightness into rgbLed methods.

      I was trying to use nested classes but I had problems with Meta Object Compiler, Is there any way to fix this issue?

      So, I write the code as follow:

      #include <QObject>
      #include <QDebug>
      #include <QtQml>
      #include <iostream>
      
      using namespace std;
      
      class brightness : public QObject
      {
          Q_OBJECT
      public:
          explicit brightness(QObject *parent = 0);
      
      public slots:
          void brightnessText(const QString& in);
      private:
          bool flag = 0;
      };
      
      class rgbLed : public QObject
      {
          Q_OBJECT
          Q_PROPERTY(int bright READ bright WRITE setBright NOTIFY brightChanged)
      public:
          explicit rgbLed(QObject *parent = nullptr);
          int regresion_red(int red);
          int regresion_green(int green);
          int regresion_blue(int blue);
      
          Q_INVOKABLE int bright();
          Q_INVOKABLE int setBright(int x);
          Q_INVOKABLE void add(rgbLed *x);
      
      
          int r;
          int g;
          int b;
          int r2;
          int g2;
          int b2;
          int brightValue;
          int myBrightness;
          QStringList list;
          QString my_in;
      
          int red = 0;
          int green = 0;
          int blue = 0;
          int pos = 0 ;
          bool flag = 0;
          int x;
      
      signals:
          void brightChanged(int x);
      
      public slots:
          void rgbRecive(const QString &in);
      };
      
      #endif // RGBLED_H
      
      sierdzioS 離線
      sierdzioS 離線
      sierdzio
      Moderators
      寫於 最後由 編輯
      #2

      @Juancinho_cardecan said in Nested class in Qt5:

      I was trying to use nested classes but I had problems with Meta Object Compiler, Is there any way to fix this issue?

      What problems?

      Generally what you describe should work but I'm half-guessing. I don't know how are you calling the variables, managing them etc.

      If you get moc parsing issues you can split your classes into 2 separate files. But most of the time MOC is clever enough to handle it without such need.

      (Z(:^

      J 1 條回覆 最後回覆
      3
      • J 離線
        J 離線
        Juancinho_cardecan
        寫於 最後由 編輯
        #3
        此回覆已被刪除!
        1 條回覆 最後回覆
        0
        • sierdzioS sierdzio

          @Juancinho_cardecan said in Nested class in Qt5:

          I was trying to use nested classes but I had problems with Meta Object Compiler, Is there any way to fix this issue?

          What problems?

          Generally what you describe should work but I'm half-guessing. I don't know how are you calling the variables, managing them etc.

          If you get moc parsing issues you can split your classes into 2 separate files. But most of the time MOC is clever enough to handle it without such need.

          J 離線
          J 離線
          Juancinho_cardecan
          寫於 最後由 編輯
          #4

          @sierdzio Thanks for the reply.
          In my cpp, I want to display the variable brightValue inside the method rgbRecive that belongs to rgbLed class, brightValue belongs to brightness class and my final porpouse is to call this variable from the function rgbRecive .
          This is the following code:

          void rgbLed::rgbRecive(const QString &in)
          {
           
              QStringList listNew = in.split(",");
              QStringList a_list = listNew[0].split("(");
              QStringList b_list = listNew[2].split(")");
              /
           
              red = a_list[1].toInt(&flag);
              green = listNew[1].toInt(&flag);
              blue = b_list[0].toInt(&flag);
           
              r2 = regresion_red(red);
              g2 = regresion_green(green);
              b2 = regresion_blue(blue);
           
              r = (brightValue * r2) / 10 ;
              g = (brightValue * g2) / 10 ;
              b = (brightValue * b2) / 10 ;
           
              qDebug() << "BrightValue from other class:" << brightValue;
           
          }
           
           
          void rgbLed::brightness::brightnessText(const QString &in)
          {
          ;
              QString Bright = in;
              int brightValue;
              brightValue = Bright.toInt(&flag);
          }
          

          If I nest in my .h the class brightness inside the rgbLed class the code looks like this:

          class rgbLed : public QObject
          {
              Q_OBJECT
              class brightness : public QObject
              {
                  Q_OBJECT
              public:
                  explicit brightness(QObject *parent = 0);
           
              public slots:
                  void brightnessText(const QString& in);
              private:
                  bool flag = 0;
              };
           
              Q_PROPERTY(int bright READ bright WRITE setBright NOTIFY brightChanged)
          public:
              explicit rgbLed(QObject *parent = nullptr);
              int regresion_red(int red);
              int regresion_green(int green);
              int regresion_blue(int blue);
           
              Q_INVOKABLE int bright();
              Q_INVOKABLE int setBright(int x);
              Q_INVOKABLE void add(rgbLed *x);
           
           
              int r;
              int g;
              int b;
              int r2;
              int g2;
              int b2;
              int brightValue;
              int myBrightness;
              QStringList list;
              QString my_in;
           
              int red = 0;
              int green = 0;
              int blue = 0;
              int pos = 0 ;
              bool flag = 0;
              int x;
           
          signals:
              void brightChanged(int x);
           
          public slots:
              void rgbRecive(const QString &in);
          };
          

          After I implemented the code, I tried to compiled and got the following error
          Error: Meta object features not supported for nested classes
          [Makefile:821: moc_rgbLed.cpp] Error 1

          jsulmJ 1 條回覆 最後回覆
          0
          • J Juancinho_cardecan

            @sierdzio Thanks for the reply.
            In my cpp, I want to display the variable brightValue inside the method rgbRecive that belongs to rgbLed class, brightValue belongs to brightness class and my final porpouse is to call this variable from the function rgbRecive .
            This is the following code:

            void rgbLed::rgbRecive(const QString &in)
            {
             
                QStringList listNew = in.split(",");
                QStringList a_list = listNew[0].split("(");
                QStringList b_list = listNew[2].split(")");
                /
             
                red = a_list[1].toInt(&flag);
                green = listNew[1].toInt(&flag);
                blue = b_list[0].toInt(&flag);
             
                r2 = regresion_red(red);
                g2 = regresion_green(green);
                b2 = regresion_blue(blue);
             
                r = (brightValue * r2) / 10 ;
                g = (brightValue * g2) / 10 ;
                b = (brightValue * b2) / 10 ;
             
                qDebug() << "BrightValue from other class:" << brightValue;
             
            }
             
             
            void rgbLed::brightness::brightnessText(const QString &in)
            {
            ;
                QString Bright = in;
                int brightValue;
                brightValue = Bright.toInt(&flag);
            }
            

            If I nest in my .h the class brightness inside the rgbLed class the code looks like this:

            class rgbLed : public QObject
            {
                Q_OBJECT
                class brightness : public QObject
                {
                    Q_OBJECT
                public:
                    explicit brightness(QObject *parent = 0);
             
                public slots:
                    void brightnessText(const QString& in);
                private:
                    bool flag = 0;
                };
             
                Q_PROPERTY(int bright READ bright WRITE setBright NOTIFY brightChanged)
            public:
                explicit rgbLed(QObject *parent = nullptr);
                int regresion_red(int red);
                int regresion_green(int green);
                int regresion_blue(int blue);
             
                Q_INVOKABLE int bright();
                Q_INVOKABLE int setBright(int x);
                Q_INVOKABLE void add(rgbLed *x);
             
             
                int r;
                int g;
                int b;
                int r2;
                int g2;
                int b2;
                int brightValue;
                int myBrightness;
                QStringList list;
                QString my_in;
             
                int red = 0;
                int green = 0;
                int blue = 0;
                int pos = 0 ;
                bool flag = 0;
                int x;
             
            signals:
                void brightChanged(int x);
             
            public slots:
                void rgbRecive(const QString &in);
            };
            

            After I implemented the code, I tried to compiled and got the following error
            Error: Meta object features not supported for nested classes
            [Makefile:821: moc_rgbLed.cpp] Error 1

            jsulmJ 離線
            jsulmJ 離線
            jsulm
            Lifetime Qt Champion
            寫於 最後由 編輯
            #5

            @Juancinho_cardecan Why do you want to use nested classes? Especially if both are QObject?

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

            J 1 條回覆 最後回覆
            4
            • sierdzioS 離線
              sierdzioS 離線
              sierdzio
              Moderators
              寫於 最後由 編輯
              #6

              Oh that kind of nesting. Your original post has different code.

              MOC does not support that. You need to use another solution, maybe some some namespaces etc. if you really need it.

              (Z(:^

              1 條回覆 最後回覆
              2
              • mrjjM 離線
                mrjjM 離線
                mrjj
                Lifetime Qt Champion
                寫於 最後由 編輯
                #7

                Hi
                Move the class brightness : public QObject to its own .h and .cpp files
                instead and just include it in class rgbLed.
                If you doing the nested class for easy access, you can just make the classes friends or
                simply provide access functions. Adding access function with Creator is fast. Just right click it and go to the refacor menu.

                1 條回覆 最後回覆
                1
                • jsulmJ jsulm

                  @Juancinho_cardecan Why do you want to use nested classes? Especially if both are QObject?

                  J 離線
                  J 離線
                  Juancinho_cardecan
                  寫於 最後由 編輯
                  #8

                  @jsulm I'm doing nested class for easy access to the variable brightValue inside a different class (In this case brightness class)

                  mrjjM J jsulmJ 3 條回覆 最後回覆
                  0
                  • J Juancinho_cardecan

                    @jsulm I'm doing nested class for easy access to the variable brightValue inside a different class (In this case brightness class)

                    mrjjM 離線
                    mrjjM 離線
                    mrjj
                    Lifetime Qt Champion
                    寫於 最後由 編輯
                    #9

                    @Juancinho_cardecan
                    Since nested classes will never fly with MOC then you have to use other design.
                    Use Friends classes
                    https://www.geeksforgeeks.org/friend-class-function-cpp/
                    For same level of easy access even its bad for encapsulation
                    Using access functions is also a possibility as that is just more clean.

                    1 條回覆 最後回覆
                    2
                    • J Juancinho_cardecan

                      @jsulm I'm doing nested class for easy access to the variable brightValue inside a different class (In this case brightness class)

                      J 離線
                      J 離線
                      Juancinho_cardecan
                      寫於 最後由 編輯
                      #10

                      @Juancinho_cardecan Tanks for your support.
                      In mi case the variables that I would want to manage are in a public slot.
                      Could i change my function brightnessText as a friend in order to take values inside the function belonging to a slot?

                      Something such as:

                      #ifndef RGBLED_H
                      #define RGBLED_H
                      
                      class brightness : public QObject
                      {
                          Q_OBJECT
                      
                      public slots:
                          friend void brightnessText(const QString& in);
                      

                      and then accesss to the variables inside that function in my .cpp calling those variables from the other method rgbRecive:

                      void rgbLed::brightness::brightnessText(const QString &in)
                      {
                          QString Bright = in;
                          int brightValue;
                          brightValue = Bright.toInt(&flag);
                      }
                      void rgbLed::rgbRecive(const QString &in)
                      {
                       
                          QStringList listNew = in.split(",");
                          QStringList a_list = listNew[0].split("(");
                          QStringList b_list = listNew[2].split(")");
                          /
                       
                          red = a_list[1].toInt(&flag);
                          green = listNew[1].toInt(&flag);
                          blue = b_list[0].toInt(&flag);
                       
                          r2 = regresion_red(red);
                          g2 = regresion_green(green);
                          b2 = regresion_blue(blue);
                       
                          r = (brightValue * r2) / 10 ;
                          g = (brightValue * g2) / 10 ;
                          b = (brightValue * b2) / 10 ;
                       
                          qDebug() << "BrightValue from other class:" << brightValue;
                       
                      }
                       
                       
                      void brightness::brightnessText(const QString &in)
                      {
                      ;
                          QString Bright = in;
                          int brightValue;
                          brightValue = Bright.toInt(&flag);
                      }
                      
                      1 條回覆 最後回覆
                      0
                      • mrjjM 離線
                        mrjjM 離線
                        mrjj
                        Lifetime Qt Champion
                        寫於 最後由 編輯
                        #11

                        Hi
                        Actually i want you to make the outer class a friend of the inner class so when inner class
                        is moved to own files, the outer class can access all private variables also in the (was) nested class
                        so that the effect is the same as a nested class.

                        Doing
                        friend void brightnessText(const QString& in);
                        allows that function to access private members (in brightness class) when defined outside but im not sure that is what you want/need
                        since a normal slot can do that already.

                        I though you wanted something like

                        class B;
                        
                        class A
                        {
                            int val; // this is private
                            friend B;
                        };
                        
                        class B
                        {
                            A obj; // like the nested class.
                            void func()
                            {
                                obj.val = 100; // this is not possible without friend
                            }
                        };
                        
                        J 1 條回覆 最後回覆
                        2
                        • J Juancinho_cardecan

                          @jsulm I'm doing nested class for easy access to the variable brightValue inside a different class (In this case brightness class)

                          jsulmJ 離線
                          jsulmJ 離線
                          jsulm
                          Lifetime Qt Champion
                          寫於 最後由 編輯
                          #12

                          @Juancinho_cardecan said in Nested class in Qt5:

                          I'm doing nested class for easy access to the variable brightValue inside a different class

                          This is really not a reason to use nested classes. You should think about clean design instead. Why not use getter/setter to access private fields?

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

                          1 條回覆 最後回覆
                          4
                          • mrjjM mrjj

                            Hi
                            Actually i want you to make the outer class a friend of the inner class so when inner class
                            is moved to own files, the outer class can access all private variables also in the (was) nested class
                            so that the effect is the same as a nested class.

                            Doing
                            friend void brightnessText(const QString& in);
                            allows that function to access private members (in brightness class) when defined outside but im not sure that is what you want/need
                            since a normal slot can do that already.

                            I though you wanted something like

                            class B;
                            
                            class A
                            {
                                int val; // this is private
                                friend B;
                            };
                            
                            class B
                            {
                                A obj; // like the nested class.
                                void func()
                                {
                                    obj.val = 100; // this is not possible without friend
                                }
                            };
                            
                            J 離線
                            J 離線
                            Juancinho_cardecan
                            寫於 最後由 編輯
                            #13

                            @mrjj Hi

                            I've been tried to implement your recommendation and also with setters/getters but at time that I want to pass the brightValue from the function void brightness::brightnessText(const QString &in) into the function void rgbLed::rgbRecive(const QString &in) unfortunately the variable b takes a random value inside the method rgbRecive:

                            This is the following code:

                            class rgbLed;
                            
                            class brightness : public QObject
                            {
                                Q_OBJECT
                            public:
                                explicit brightness(QObject *parent = 0);
                                friend rgbLed;
                                void setBrightValue(int newbrightValueMember)
                                {
                                    brightValueMember = newbrightValueMember;
                                };
                                int getBrightValue()
                                {
                                    return brightValueMember;
                                }
                            
                                bool flag = 0;
                                int brightValueMember;
                            
                            public slots:
                                void brightnessText(const QString& in);
                            };
                            
                            class rgbLed : public QObject
                            {
                                Q_OBJECT
                                Q_PROPERTY(int bright READ brigfht WRITE setBright NOTIFY brightChanged)
                            public:
                                explicit rgbLed(QObject *parent = nullptr);
                                brightness obj;
                                int regresion_red(int red);
                                int regresion_green(int green);
                                int regresion_blue(int blue);
                            
                                Q_INVOKABLE int bright();
                                Q_INVOKABLE int setBright(int x);
                                Q_INVOKABLE void add(rgbLed *x);
                            
                            
                                int r;
                                int g;
                                int b;
                                int r2;
                                int g2;
                                int b2;
                                int brightValue;
                                int myBrightness;
                                QStringList list;
                                QString my_in;
                            
                                int red = 0;
                                int green = 0;
                                int blue = 0;
                                int pos = 0 ;
                                bool flag = 0;
                                int x;
                            
                            signals:
                                void brightChanged(int x);
                            
                            public slots:
                                void rgbRecive(const QString &in);
                            };
                            
                            

                            and in my .cpp:

                            void brightness::brightnessText(const QString &in)
                            {
                            
                                QString Bright = in;
                                int brightValue;
                                brightValue = Bright.toInt(&flag);
                                setBrightValue(brightValue);
                            
                                qDebug() << "bright: " << brightValue;
                            }
                            
                            void rgbLed::rgbRecive(const QString &in)
                            {
                                qDebug() << "ColorPicked:" << in;
                            
                                QStringList listNew = in.split(",");
                                QStringList a_list = listNew[0].split("(");
                                QStringList b_list = listNew[2].split(")");
                            
                                int b = obj.getBrightValue();
                                qDebug() << "Value: " << b;
                            }
                            

                            Could anyone see why b is taken a random value?

                            jsulmJ 1 條回覆 最後回覆
                            0
                            • J Juancinho_cardecan

                              @mrjj Hi

                              I've been tried to implement your recommendation and also with setters/getters but at time that I want to pass the brightValue from the function void brightness::brightnessText(const QString &in) into the function void rgbLed::rgbRecive(const QString &in) unfortunately the variable b takes a random value inside the method rgbRecive:

                              This is the following code:

                              class rgbLed;
                              
                              class brightness : public QObject
                              {
                                  Q_OBJECT
                              public:
                                  explicit brightness(QObject *parent = 0);
                                  friend rgbLed;
                                  void setBrightValue(int newbrightValueMember)
                                  {
                                      brightValueMember = newbrightValueMember;
                                  };
                                  int getBrightValue()
                                  {
                                      return brightValueMember;
                                  }
                              
                                  bool flag = 0;
                                  int brightValueMember;
                              
                              public slots:
                                  void brightnessText(const QString& in);
                              };
                              
                              class rgbLed : public QObject
                              {
                                  Q_OBJECT
                                  Q_PROPERTY(int bright READ brigfht WRITE setBright NOTIFY brightChanged)
                              public:
                                  explicit rgbLed(QObject *parent = nullptr);
                                  brightness obj;
                                  int regresion_red(int red);
                                  int regresion_green(int green);
                                  int regresion_blue(int blue);
                              
                                  Q_INVOKABLE int bright();
                                  Q_INVOKABLE int setBright(int x);
                                  Q_INVOKABLE void add(rgbLed *x);
                              
                              
                                  int r;
                                  int g;
                                  int b;
                                  int r2;
                                  int g2;
                                  int b2;
                                  int brightValue;
                                  int myBrightness;
                                  QStringList list;
                                  QString my_in;
                              
                                  int red = 0;
                                  int green = 0;
                                  int blue = 0;
                                  int pos = 0 ;
                                  bool flag = 0;
                                  int x;
                              
                              signals:
                                  void brightChanged(int x);
                              
                              public slots:
                                  void rgbRecive(const QString &in);
                              };
                              
                              

                              and in my .cpp:

                              void brightness::brightnessText(const QString &in)
                              {
                              
                                  QString Bright = in;
                                  int brightValue;
                                  brightValue = Bright.toInt(&flag);
                                  setBrightValue(brightValue);
                              
                                  qDebug() << "bright: " << brightValue;
                              }
                              
                              void rgbLed::rgbRecive(const QString &in)
                              {
                                  qDebug() << "ColorPicked:" << in;
                              
                                  QStringList listNew = in.split(",");
                                  QStringList a_list = listNew[0].split("(");
                                  QStringList b_list = listNew[2].split(")");
                              
                                  int b = obj.getBrightValue();
                                  qDebug() << "Value: " << b;
                              }
                              

                              Could anyone see why b is taken a random value?

                              jsulmJ 離線
                              jsulmJ 離線
                              jsulm
                              Lifetime Qt Champion
                              寫於 最後由 jsulm 編輯
                              #14

                              @Juancinho_cardecan Where do you call brightness::brightnessText?
                              Do you call it on rgbLed::obj or maybe on another brightness instance?

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

                              J 1 條回覆 最後回覆
                              1
                              • jsulmJ jsulm

                                @Juancinho_cardecan Where do you call brightness::brightnessText?
                                Do you call it on rgbLed::obj or maybe on another brightness instance?

                                J 離線
                                J 離線
                                Juancinho_cardecan
                                寫於 最後由 編輯
                                #15

                                @jsulm I called here after your words but the value doesn't change:

                                void rgbLed::rgbRecive(const QString &in)
                                {
                                qDebug() << "ColorPicked:" << in;

                                QStringList listNew = in.split(",");
                                QStringList a_list = listNew[0].split("(");
                                QStringList b_list = listNew[2].split(")");
                                
                                obj.brightnessText(in);
                                int b = obj.getBrightValue();
                                qDebug() << "Value: " << b;
                                

                                }

                                jsulmJ 1 條回覆 最後回覆
                                0
                                • J Juancinho_cardecan

                                  @jsulm I called here after your words but the value doesn't change:

                                  void rgbLed::rgbRecive(const QString &in)
                                  {
                                  qDebug() << "ColorPicked:" << in;

                                  QStringList listNew = in.split(",");
                                  QStringList a_list = listNew[0].split("(");
                                  QStringList b_list = listNew[2].split(")");
                                  
                                  obj.brightnessText(in);
                                  int b = obj.getBrightValue();
                                  qDebug() << "Value: " << b;
                                  

                                  }

                                  jsulmJ 離線
                                  jsulmJ 離線
                                  jsulm
                                  Lifetime Qt Champion
                                  寫於 最後由 編輯
                                  #16

                                  @Juancinho_cardecan Called where? And did you call it on rgbLed::obj?

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

                                  J 2 條回覆 最後回覆
                                  2
                                  • jsulmJ jsulm

                                    @Juancinho_cardecan Called where? And did you call it on rgbLed::obj?

                                    J 離線
                                    J 離線
                                    Juancinho_cardecan
                                    寫於 最後由 編輯
                                    #17
                                    此回覆已被刪除!
                                    1 條回覆 最後回覆
                                    0
                                    • jsulmJ jsulm

                                      @Juancinho_cardecan Called where? And did you call it on rgbLed::obj?

                                      J 離線
                                      J 離線
                                      Juancinho_cardecan
                                      寫於 最後由 編輯
                                      #18

                                      @jsulm No I din't call it on rgbLed::obj, I called it inside the function void rgbLed::rgbRecive

                                      1 條回覆 最後回覆
                                      0
                                      • mrjjM 離線
                                        mrjjM 離線
                                        mrjj
                                        Lifetime Qt Champion
                                        寫於 最後由 編輯
                                        #19

                                        Hi
                                        So here

                                        void rgbLed::rgbRecive(const QString &in)
                                        {
                                        obj.brightnessText(in);
                                        int b = obj.getBrightValue();
                                        

                                        b is not what you expect ?

                                        J 1 條回覆 最後回覆
                                        1
                                        • mrjjM mrjj

                                          Hi
                                          So here

                                          void rgbLed::rgbRecive(const QString &in)
                                          {
                                          obj.brightnessText(in);
                                          int b = obj.getBrightValue();
                                          

                                          b is not what you expect ?

                                          J 離線
                                          J 離線
                                          Juancinho_cardecan
                                          寫於 最後由 編輯
                                          #20

                                          @mrjj yes it's not what I'm expecting, it might be changing all the time but the value is zero always.

                                          mrjjM 1 條回覆 最後回覆
                                          0

                                          • 登入

                                          • Login or register to search.
                                          • 第一個貼文
                                            最後的貼文
                                          0
                                          • 版面
                                          • 最新
                                          • 標籤
                                          • 熱門
                                          • 使用者
                                          • 群組
                                          • 搜尋
                                          • Get Qt Extensions
                                          • Unsolved