Pregunta

I am trying to set the text of a line edit that is found using findChild()

mainwindow.cpp

void MainWindow::setValue(QString line, QString value){
    QLineEdit * edit = centralWidget()->findChild<QLineEdit *>(line);
    edit.setText(value);
}

However, I get an error on edit.setText(value); saying left of .setText must be class/struct/union.

How do I properly set the text of the child name line to be value?

¿Fue útil?

Solución

You need to use the -> operator as edit is a pointer:

edit->setText(value);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top