Quantcast
Channel: Installation and Deployment
Viewing all articles
Browse latest Browse all 22112

preparing query for QSqlQUeryModel

$
0
0
hy to all I’m trying to prepare a query and then to bind new values to it. this is what I managed to do QSqlQuery query;         query.prepare("INSERT INTO cliente(calo, titoloargento, nomecliente) "                       "VALUES (?, ?, ?)");         query.addBindValue(ui->doubleSpinBox_calo->value());         query.addBindValue(ui->spinBox->value());         query.addBindValue(ui->lineEdit_nomeCliente->text());         query.exec() and this works fine, now I want to retrieve info from the database, and I’m using QSqlQueryModel. It works fine until this point: this->model=new QSqlQueryModel();     model->setQuery("SELECT nomecliente FROM cliente");     ui->tableView->setVisible(true);     ui->tableView->setModel(model); but when I want to add a WHERE clause with values taken from a label I can’t manage. I’ve tried this:         this->model=new QSqlQueryModel();         QSqlQuery query;         query.prepare("SELECT nomecliente FROM cliente WHERE nomeclient=?");         query.addBindValue(ui->lineEdit_6->text());         model->setQuery(query);         ui->tableView->setVisible(true);         ui->tableView->setModel(model); but nothing happens… anybody has some suggestions??

Viewing all articles
Browse latest Browse all 22112

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>