PDA

View Full Version : How to check the checkbox based on users selection from a message window.



rookee
9th December 2015, 16:34
Hello All,

I'm trying to make the checkBox status back to checked again if users selection is "NO" on the pop up message window. I also want to flash messages when the selection is done. Please help. Thanks in advance.


void MainWindow::on_checkBox_clicked()
{

if(ui->checkBox->isChecked())
{
cbx=1;
//Something

} if(!ui->checkBox->isChecked()){
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this,"Test", "Do you want to stop logging?", QMessageBox::Yes|QMessageBox::No);
if(reply==QMessageBox::Yes){
// A message should flash saying "Logging is stopped"
qDebug()<< "Logging is stopped";
cbx=0;

}else {
qDebug()<<"Logging will continue";
// A message should flash saying "Logging will continue" and Keep the checkBox status back to checked again.

}

}

}

Can someone help me understand what qDebug statements are used for. The following is what I read on the Qt website. I couldn't get it, if someone can explain it little more detailed I would really appreciate it. Can I use qDebug to flash the messages that I want to.

The QDebug class provides an output stream for debugging information.
QDebug is used whenever the developer needs to write out debugging or tracing information to a device, file, string or console.

Vikram.Saralaya
9th December 2015, 17:07
QDebug is used to print debug messages. These messages are not meant for the user but only for the developer.

To flash a message on the screen you can use:

QMessageBox
QErrorMessage
QDialog


These options display a message and expect the user to click "OK".
If you want to "flash" the message and hide it automatically you can use a QTimer with the above options.

rookee
9th December 2015, 17:13
When I uncheck the checkbox I get the popup window but when I select "NO" on the popup window I want to set the checkBox status back to checked. How can I achieve that?

Vikram.Saralaya
9th December 2015, 17:56
else {
qDebug()<<"Logging will continue";
ui->checkBox->setChecked(true);
}

rookee
9th December 2015, 18:24
Thanks a lot Vikram. It's working. :)