I'll try the example, but it sure seems like a click on a pushbutton when it's disabled is "remembered" and executes the associated slot when the button is enabled.
Here's the code fragment:
QString filename
= crn
+ "_" + dogName
+ "_" + QString::number(imageSuffix
) + ".png";
filename.
replace(QRegExp("[<>:\"/\\|?*]"),
"");
pb->setWindowModality(Qt::ApplicationModal);
pb->setVisible(true);
//pb->show() ;
ui->Accept->setEnabled(false);
ui->Freeze->setEnabled(false);
ui->Reject->setEnabled(false);
bool success = stillImage.save(imageDirectory + filename) ;
if (!success )
{
qDebug() << "something went wrong";
}
qDebug() << imageDirectory + filename;
qDebug() << crn;
qDebug()<< filename;
qry.prepare("INSERT INTO title_pictures (crn,file_name) "
"VALUES( :crn, :file_name);" );
qry.bindValue(":crn", crn);
qry.bindValue(":file_name", filename);
int rows_affected = SqlUtils::exec_query(qry,false,false);
qDebug() << rows_affected;
// Save the image here.
settings.setValue("image_suffix",imageSuffix++) ;
emit startCapture(true);
pb->setVisible(false);
//pb->hide() ;
ui->Accept->setEnabled(true);
ui->Freeze->setEnabled(true);
ui->Reject->setEnabled(true);
QString filename = crn + "_" + dogName + "_" + QString::number(imageSuffix) + ".png";
filename.replace(QRegExp("[<>:\"/\\|?*]"), "");
pb->setWindowModality(Qt::ApplicationModal);
pb->setVisible(true);
//pb->show() ;
ui->Accept->setEnabled(false);
ui->Freeze->setEnabled(false);
ui->Reject->setEnabled(false);
QApplication::processEvents();
bool success = stillImage.save(imageDirectory + filename) ;
if (!success )
{
qDebug() << "something went wrong";
}
qDebug() << imageDirectory + filename;
qDebug() << crn;
qDebug()<< filename;
QSqlQuery qry;
qry.prepare("INSERT INTO title_pictures (crn,file_name) "
"VALUES( :crn, :file_name);" );
qry.bindValue(":crn", crn);
qry.bindValue(":file_name", filename);
int rows_affected = SqlUtils::exec_query(qry,false,false);
qDebug() << rows_affected;
// Save the image here.
settings.setValue("image_suffix",imageSuffix++) ;
emit startCapture(true);
pb->setVisible(false);
//pb->hide() ;
ui->Accept->setEnabled(true);
ui->Freeze->setEnabled(true);
ui->Reject->setEnabled(true);
To copy to clipboard, switch view to plain text mode
pb is a QProgressBar *. The long operation is the stillImage.save() (saving a QPixmap). If I click on buttons during the five second save (they are greyed out), the slot code gets executed.
Platform is raspbian.
Dave Thomas
Bookmarks