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. How obtain from input array (QLineEdit)
Forum Updated to NodeBB v4.3 + New Features

How obtain from input array (QLineEdit)

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 531 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.
  • R Offline
    R Offline
    rifky
    wrote on last edited by
    #1

    I find it difficult to pass the value from QLineEdit array, here is my snipped code, or there are alternative paths to achieve this goal?

    void Thisclass::fct()
    {
       QMultiMap<QString,int> bbuMapped;
       bbuMapped.insert("bbu3",0);
       bbuMapped.insert("bbu2",1);
    
       QLineEdit *txt_rxgain[bbuMapped.size()];
       QLineEdit ..
       QLineEdit ..
       for (int i = 0; i < bbusCount; i++) {
         txt_rxgain[i] = new QLineEdit;
         .. = new QLineEdit;
         .. = new QLineEdit;
       }
    
    
       connect(btn_loadconf[i] , &QPushButton::clicked, [this] {
            emit funcSaveForm();
       });
    
    }
    
    
    void Thisclass::funcSaveForm()
    {
    // here ,how can i obtain value from input 
    }
    
    jsulmJ 2 Replies Last reply
    0
    • R rifky

      I find it difficult to pass the value from QLineEdit array, here is my snipped code, or there are alternative paths to achieve this goal?

      void Thisclass::fct()
      {
         QMultiMap<QString,int> bbuMapped;
         bbuMapped.insert("bbu3",0);
         bbuMapped.insert("bbu2",1);
      
         QLineEdit *txt_rxgain[bbuMapped.size()];
         QLineEdit ..
         QLineEdit ..
         for (int i = 0; i < bbusCount; i++) {
           txt_rxgain[i] = new QLineEdit;
           .. = new QLineEdit;
           .. = new QLineEdit;
         }
      
      
         connect(btn_loadconf[i] , &QPushButton::clicked, [this] {
              emit funcSaveForm();
         });
      
      }
      
      
      void Thisclass::funcSaveForm()
      {
      // here ,how can i obtain value from input 
      }
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @rifky said in How obtain from input array (QLineEdit):

      or there are alternative paths to achieve this goal?

      Which goal? Please explain what you want to achieve in an understandable way.

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

      R 1 Reply Last reply
      0
      • jsulmJ jsulm

        @rifky said in How obtain from input array (QLineEdit):

        or there are alternative paths to achieve this goal?

        Which goal? Please explain what you want to achieve in an understandable way.

        R Offline
        R Offline
        rifky
        wrote on last edited by
        #3

        @jsulm said in How obtain from input array (QLineEdit):

        @rifky said in How obtain from input array (QLineEdit):

        or there are alternative paths to achieve this goal?

        Which goal? Please explain what you want to achieve in an understandable way.

        pasing value from QLineEdit after click button

        1 Reply Last reply
        0
        • R rifky

          I find it difficult to pass the value from QLineEdit array, here is my snipped code, or there are alternative paths to achieve this goal?

          void Thisclass::fct()
          {
             QMultiMap<QString,int> bbuMapped;
             bbuMapped.insert("bbu3",0);
             bbuMapped.insert("bbu2",1);
          
             QLineEdit *txt_rxgain[bbuMapped.size()];
             QLineEdit ..
             QLineEdit ..
             for (int i = 0; i < bbusCount; i++) {
               txt_rxgain[i] = new QLineEdit;
               .. = new QLineEdit;
               .. = new QLineEdit;
             }
          
          
             connect(btn_loadconf[i] , &QPushButton::clicked, [this] {
                  emit funcSaveForm();
             });
          
          }
          
          
          void Thisclass::funcSaveForm()
          {
          // here ,how can i obtain value from input 
          }
          
          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @rifky said in How obtain from input array (QLineEdit):

          QLineEdit *txt_rxgain[bbuMapped.size()];

          You have to declare *txt_rxgain as class member variable to be able to access it outside of fct().
          Then you can easily access it in funcSaveForm().
          This is basic C++.

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

          1 Reply Last reply
          0
          • R Offline
            R Offline
            rifky
            wrote on last edited by rifky
            #5

            solved :

            QLineEdit * raw_rxgain = txt_rxgain[i];
            connect(btn_loadconf[i] , &QPushButton::clicked, [this] {
                    QJsonObject tempObjValue;
                    tempObjValue.insert("rxgain",raw_rxgain->text().toInt());
                    emit funcSaveForm(tempObjValue);
             });
            
            }
            
            void Thisclass::funcSaveForm(QJsonObject object)
            {
            qDebug()<<"clicked funcSaveForm"<< object;
            }
            
            JonBJ 1 Reply Last reply
            0
            • R rifky

              solved :

              QLineEdit * raw_rxgain = txt_rxgain[i];
              connect(btn_loadconf[i] , &QPushButton::clicked, [this] {
                      QJsonObject tempObjValue;
                      tempObjValue.insert("rxgain",raw_rxgain->text().toInt());
                      emit funcSaveForm(tempObjValue);
               });
              
              }
              
              void Thisclass::funcSaveForm(QJsonObject object)
              {
              qDebug()<<"clicked funcSaveForm"<< object;
              }
              
              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @rifky
              Up to you, but (if this is connect()ed with DirectConnection) wouldn't it be faster to go:

              void Thisclass::funcSaveForm(const QJsonObject &object)
              

              ?

              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