Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to get lineEdit content which is created dynamically?

How to get lineEdit content which is created dynamically?

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 4 Posters 6.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.
  • A Offline
    A Offline
    aurora
    wrote on last edited by
    #1

    In my program i'm creating lineEdit widget dynamically whenever a user enters "ADD" button.
    But i'm not able to access the text of that dynamically created lineEdit.
    my code is as follows...
    @ on_pushButton_ADD_clicked()
    {
    QLineEdit *lineEdit = new QLineEdit;
    QLabel *label = new QLabel;
    ui->gridLayout->addWidget( label,LayoutCount,0 );
    ui->gridLayout->addWidget( lineEdit,LayoutCount,1 );
    .................
    }@

    for accessing the dynamically created lineEdit i'm trying as follows..

    @KeyList.append(ui->gridLayout->lineEdit->text());
    @

    But i'm getting error....
    Please help me....HOW CAN I ACCESS lineEdit->text?

    1 Reply Last reply
    0
    • H Offline
      H Offline
      HuXiKa
      wrote on last edited by
      #2

      Layouts do not contain widgets, but layout items.
      So, if you want to access the widgets, first browse through the list of layout items, and access the widget or child layout in the item.

      If you can find faults of spelling in the text above, you can keep them.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        Better yet, when you create the line edit, simply keep a pointer to it in some kind of suitable data structure (a QList, for instance).

        1 Reply Last reply
        0
        • A Offline
          A Offline
          aurora
          wrote on last edited by
          #4

          [quote author="Andre" date="1319011099"]Better yet, when you create the line edit, simply keep a pointer to it in some kind of suitable data structure (a QList, for instance).[/quote]

          please may i know how can i do that...? some format atleast....

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            [quote author="aurora" date="1319013560"]
            please may i know how can i do that...? some format atleast....[/quote]

            @
            QList<QLineEdit *> lineEditList;
            lineEditList.add(lineEdit);
            @

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • A Offline
              A Offline
              aurora
              wrote on last edited by
              #6

              [quote author="Volker" date="1319028037"]
              [quote author="aurora" date="1319013560"]
              please may i know how can i do that...? some format atleast....[/quote]

              @
              QList<QLineEdit *> lineEditList;
              lineEditList.add(lineEdit);
              @
              [/quote]

              THANKS A LOT...IT HELPED ME...:)

              but now using combox also....
              so i declared like this...
              @QList<QComboBox *> TagList;@
              but getting error saying that "'ComboBox' was not declared in this scope"!!!!

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

                So... Did you make sure it is declared then? Try to put
                @
                #include <QtGui/QComboBox>
                @
                at the top of the file where you get this complaint.

                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