0

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?

Daniel Hedberg
  • 5,677
  • 4
  • 36
  • 61
moesef
  • 4,641
  • 16
  • 51
  • 68

1 Answers1

0

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

edit->setText(value);
Daniel Hedberg
  • 5,677
  • 4
  • 36
  • 61