Results 1 to 2 of 2

Thread: how to find child widget from parent.

  1. #1
    Join Date
    Jun 2014
    Posts
    46
    Thanks
    6
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default how to find child widget from parent.

    hi to all, I've centos7.5 and Qt 5.7 in VM. I am trying to get child (lineEdit) from parent. I tried like this :-

    Qt Code:
    1. void dialogAddNewRecord::insert_intoDB(QString *name, qint32 *stock, qint32 *rate, qint32 *number)
    2. {
    3. logindlg = new dialogLogin(this);
    4.  
    5.  
    6. QLineEdit *uname_l = logindlg->findChild<QLineEdit*>("lineEditUserNameLoginForm");
    7. QString uname = uname_l->text().trimmed();
    8. qDebug() << "uname = " << uname;
    9. qDebug() << uname_l;
    10. }
    To copy to clipboard, switch view to plain text mode 
    this shows following output:-
    Qt Code:
    1. uname = ""
    2. QLineEdit(0x1c323e0, name="lineEditUserNameLoginForm")
    To copy to clipboard, switch view to plain text mode 
    how to get child lineEdit in form.
    Last edited by rahulvishwakarma; 24th March 2020 at 10:51.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,521
    Thanked 278 Times in 273 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to find child widget from parent.

    But what's the problem? You found what you were looking for. Maybe the problem is that you are creating a new instance of the dialogue in line 3.

  3. The following user says thank you to Lesiok for this useful post:

    rahulvishwakarma (24th March 2020)

Similar Threads

  1. How to resize parent widget when child widget is resized
    By ainne810329 in forum Qt Programming
    Replies: 4
    Last Post: 29th November 2011, 08:47
  2. Replies: 1
    Last Post: 11th March 2011, 20:34
  3. Replies: 7
    Last Post: 14th January 2010, 09:47
  4. Replies: 4
    Last Post: 3rd October 2009, 09:19
  5. Child-Parent Widget??
    By anupamgee in forum Qt Programming
    Replies: 1
    Last Post: 11th May 2009, 14:17

Tags for this Thread

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.