Reading database table content into a text edit
The following code is used by me to read database table contents into a Qtableview but the setmodel is not working for Lineedit! How can I display the same contents in the lineedit?
QSqlQueryModel * modal = new QSqlQueryModel();
QSqlQuery* qry = new QSqlQuery(conn.mydb);
qry->prepare("select uname from einfo");
ui->tableView->setModel(modal); //working properly
ui->textEdit->setmodel(modal); //not working becauese textedits dont support setmodel()
Here the Conn object is used to provide the necessary database connection( it is working properly!)
what is the text edit supposed to show? All rows returned by the query?
@raven-worx yes it has to show all rows
then you need to construct the string yourself. Either traverse the query or the model's rows directly and set it to the textedit.
Pablo J. Rogina
@Lasith are you sure that all the rows returned by query should show in QTextEdit object? It doesn't look the better widget for the job...