erfnemati
erfnemati

Reputation: 13

Display data real time in QT c++ from db

Sth like this

The project has a page with this schema:

There is a QlineEdit in integer and a texBox(or can be use another widget) I want to Display the relevant cell of database(sqlite with query for example:select * frome dbName where code='QlineEdit integer') in textBox, But no with a button action, real time!

As I search it can be possible by textchange() or QLineEdit::editingFinished(), But don't know how

Upvotes: -1

Views: 534

Answers (1)

erfnemati
erfnemati

Reputation: 13

It works like this for the who one later see:

connect(ui->nameLine,SIGNAL(textChanged(QString)),this,
SLOT(updateLineEditText(QString)));

void MainWindow::updateLineEditText(QString cd) {
ui->nameLabel->setText("");
QString textEditString(cd);
QString flname;
MainWindow conn;
conn.connopen();
QSqlQuery query;
   query.exec("SELECT Firstname, Lastname, Code  FROM Election WHERE Code='"+cd+"'");
   while (query.next()) {
        flname.append( query.value(0).toString() + " ");
        flname.append( query.value(1).toString() + " ");
        ui->nameLabel->setText(flname);

Hope useful;

Upvotes: 0

Related Questions