Results 1 to 9 of 9

Thread: how to access LINE EDIT'S value

  1. #1
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default how to access LINE EDIT'S value

    im using the following steps to create LINE EDITS
    Qt Code:
    1. void DynamicControls::createLineEdit(QString Wstr,QString WTip,int x,int y)
    2. {
    3. lineEdit=new QLineEdit(Wstr);
    4. lineEdit->setToolTip(WTip);
    5. layout->addWidget(lineEdit,x,y);
    6. }
    To copy to clipboard, switch view to plain text mode 

    from main im creating LINEEDITS BY FOLLOWING CODE
    Qt Code:
    1. main()
    2. {
    3. w.createLineEdit("id","id",1,1);
    4. w.createLineEdit("name","name",2,2);
    5. //here i want to access id.text, name.text
    6. }
    To copy to clipboard, switch view to plain text mode 

    how can i access in main?
    id's value and name value?


    pls guide me
    Bala

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to access LINE EDIT'S value

    put you lineedits in a QMap or QHash.
    Qt Code:
    1. ...
    2. QMap<QString, QLineEdit *> lineEdits;
    3. lineEdits.insert("id", new QLineEdit(this));
    4. ...
    5. QLineEdit *le = lineEdits.value("id");
    6. if (!le)
    7. return;
    8. le->setText("text");
    9. ...
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to access LINE EDIT'S value

    in your DynamicControls class make function that will return the linedit pointer... then you can use w.getlinedit1->text()

    EDIT: i m late

  4. #4
    Join Date
    Dec 2007
    Posts
    627
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to access LINE EDIT'S value

    Set this property @ the time of creating line edits.
    Qt Code:
    1. yourLineEdit->setAccessibleName("anyNameWithID");
    To copy to clipboard, switch view to plain text mode 

    And find these line edits like this:
    Qt Code:
    1. QLineEdit *le = parentWidget->findChild<QLineEdit *>("LineEdit1");
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to yogeshgokul for this useful post:

    Walter (20th August 2009)

  6. #5
    Join Date
    Dec 2007
    Posts
    627
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to access LINE EDIT'S value

    OMG !! I must be too slow.

  7. #6
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to access LINE EDIT'S value

    Quote Originally Posted by yogeshgokul View Post
    OMG !! I must be too slow.
    why? you example is good too.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  8. #7
    Join Date
    Dec 2007
    Posts
    627
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to access LINE EDIT'S value

    Quote Originally Posted by spirit View Post
    why? you example is good too.

    I am talking about my typing speed. Until I type my answer this post got 2 answers already.

  9. The following user says thank you to yogeshgokul for this useful post:

    BalaQT (25th September 2009)

  10. #8
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: how to access LINE EDIT'S value

    in your DynamicControls class make function that will return the linedit pointer... then you can use w.getlinedit1->text()
    how to return a pointer?

    existing coding:
    Qt Code:
    1. void DynamicControls::createLineEdit(QString Wstr,QString WTip,int x,int y)
    2. {
    3. lineEdit=new QLineEdit(Wstr);
    4. lineEdit->setToolTip(WTip);
    5. layout->addWidget(lineEdit,x,y);
    6. }
    To copy to clipboard, switch view to plain text mode 

    and what will be the function call frm main?
    exist code
    Qt Code:
    1. w.createLineEdit(str,str,1,1);
    To copy to clipboard, switch view to plain text mode 


    Thanks
    Bala

  11. #9
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to access LINE EDIT'S value

    Qt Code:
    1. void DynamicControls::createLineEdit(const QString &Wstr, const QString &WTip,int x,int y)
    2. {
    3. lineEdit=new QLineEdit(Wstr);
    4. lineEdit->setToolTip(WTip);
    5. layout->addWidget(lineEdit,x,y);
    6. lineEdit->setObjectName("someUniqueId");
    7. }
    8.  
    9. QLineEdit DynamicControls::lineEdit(const QString &uniqueId) const
    10. {
    11. return findChild<QLineEdit *>(uniqueId);
    12. }
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  12. The following user says thank you to spirit for this useful post:

    BalaQT (20th August 2009)

Similar Threads

  1. how can i create array of lineedits?
    By BalaQT in forum Qt Programming
    Replies: 1
    Last Post: 20th August 2009, 08:17
  2. QTcpSocket exception.
    By Fastman in forum Qt Programming
    Replies: 9
    Last Post: 29th January 2008, 13:51
  3. Access Violation on Signal Emit
    By khagzan in forum Qt Programming
    Replies: 2
    Last Post: 25th September 2007, 22:51
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 18:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.