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 the members of dynamic form
Forum Updated to NodeBB v4.3 + New Features

Access the members of dynamic form

Scheduled Pinned Locked Moved General and Desktop
11 Posts 4 Posters 3.0k Views 1 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.
  • E Offline
    E Offline
    Exotic_Devel
    wrote on last edited by
    #1

    How do I access an existing QLineEdit in a form generated automatically with QUiLoader? For example, to get your content.

    @ MyWidget::MyWidget(QWidget *parent)
    : QWidget(parent)
    {
    QUiLoader loader;
    QFile file(":/forms/myform.ui");
    file.open(QFile::ReadOnly);
    QWidget *myWidget = loader.load(&file, this);
    file.close();

         QVBoxLayout *layout = new QVBoxLayout;
         layout->addWidget(myWidget);
         setLayout(layout);
     }
    

    @

    Assuming that there is a QLineEdit in MyWidget. How to access it?

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      You can try using some thing like this.

      QList<QLineEdit*> edits = myWidget->findChildren<QLineEdit*>();

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • E Offline
        E Offline
        Exotic_Devel
        wrote on last edited by
        #3

        How to get a specific QLineEdit on the list?
        Suppose I want to access the QLineEdit that contains the server ip. How do I know what position is he?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Give an object name to the QLineEdit then you can search using it

          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
          • dheerendraD Offline
            dheerendraD Offline
            dheerendra
            Qt Champions 2022
            wrote on last edited by
            #5

            In addition to what SGaist said, you can use the specific API

            @QList<QWidget *> widgets = parentWidget.findChildren<QWidget *>("widgetname");@

            You can look at the findChildren(..) API in Qt Documentation. It has more details.

            Dheerendra
            @Community Service
            Certified Qt Specialist
            http://www.pthinks.com

            1 Reply Last reply
            0
            • E Offline
              E Offline
              Exotic_Devel
              wrote on last edited by
              #6

              I wanted a way to catch all

              @QList<QLineEdit*> edits = myWidget->findChildren<QLineEdit*>();@

              And after finding a specific QLineEdit in list. Thus I think I save a few lines of code.

              1 Reply Last reply
              0
              • IamSumitI Offline
                IamSumitI Offline
                IamSumit
                wrote on last edited by
                #7

                [quote author="Exotic_Devel" date="1408902797"] after finding a specific QLineEdit in list. Thus I think I save a few lines of code.[/quote]

                Hii..
                Then for such case . you have following approaches.

                http://doc.qt.digia.com/qq/qq10-signalmapper.html

                hope it helps you

                Be Cute

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  What wrong with:

                  @QLineEdit *lineEdit = parentWidget->findChild<QLineEdit *>("myFunkyComboBox");@

                  ?

                  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
                  • E Offline
                    E Offline
                    Exotic_Devel
                    wrote on last edited by
                    #9

                    Sorry, that was an editing mistake

                    1 Reply Last reply
                    0
                    • E Offline
                      E Offline
                      Exotic_Devel
                      wrote on last edited by
                      #10

                      I'm using 'findChildren' to put all QLineEdit in a list and pass it as a parameter to a method. However, I do not know how to extract a specific QLineEdit the list to be able to manipulate. eg

                      @lineedits = connecdiag->findChildren<QLineEdit*>(QString(), Qt::FindDirectChildrenOnly);@

                      How to catch a QLineEdit called 'qle_port' that is in

                      @lineedits@

                      ?

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        Hi,

                        Why not search directly for QLineEdits having this name ? e.g.

                        @
                        ineedits = connecdiag->findChildren<QLineEdit*>("qle_port", Qt::FindDirectChildrenOnly);@

                        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