PDA

View Full Version : how to find child widget from parent.



rahulvishwakarma
24th March 2020, 09:46
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 :-



void dialogAddNewRecord::insert_intoDB(QString *name, qint32 *stock, qint32 *rate, qint32 *number)
{
logindlg = new dialogLogin(this);


QLineEdit *uname_l = logindlg->findChild<QLineEdit*>("lineEditUserNameLoginForm");
QString uname = uname_l->text().trimmed();
qDebug() << "uname = " << uname;
qDebug() << uname_l;
}

this shows following output:-


uname = ""
QLineEdit(0x1c323e0, name="lineEditUserNameLoginForm")

how to get child lineEdit in form.

Lesiok
24th March 2020, 12:23
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.