I'm using this code
query_p_total.prepare("SELECT :x * :y");
query_p_total.bindValue(":x", ui.peso_por_peca_label->text() );
query_p_total.bindValue(":y", ui.n_pecas_final_lineEdit->text() );
if (!query_p_total.exec()){
QString("There is an error with query.exec()!"));
}else{
while (query_p_total.next()) {
ui.peso_total_final_label->setText(query_p_total.value(0).toString());
}
}
QSqlQuery query_p_total;
query_p_total.prepare("SELECT :x * :y");
query_p_total.bindValue(":x", ui.peso_por_peca_label->text() );
query_p_total.bindValue(":y", ui.n_pecas_final_lineEdit->text() );
if (!query_p_total.exec()){
QMessageBox::critical(0, tr("Error"),
QString("There is an error with query.exec()!"));
}else{
while (query_p_total.next()) {
ui.peso_total_final_label->setText(query_p_total.value(0).toString());
}
}
To copy to clipboard, switch view to plain text mode
ui.peso_por_peca_label->text() ) has value 20.16 and ui.n_pecas_final_lineEdit->text() has value 6, then ui.peso_total_final_label should show me 120.96, but it is showing me 121. When I try to select 20.16 * 6 in the MYSQL console I get the right result, so I think there is something with QLineEdit, but what could it be? Or what else could it be?
Renan
Bookmarks