首先获取字符串 QString str = "你的字符串";QLineEdit* lineEdit=new QLineEdit;lineEdit->setText(str); 若QLineEdit控件是通过拖拽生成的,那么ui.lineEdit->setText(str);
可以直接把字符串传给QLineEdit的构造函数QLineEdit* lineEdit=new QLineEdit("Hello");