Results 1 to 5 of 5

Thread: How to check the checkbox based on users selection from a message window.

  1. #1
    Join Date
    Oct 2015
    Posts
    35
    Thanks
    11
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default How to check the checkbox based on users selection from a message window.

    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.

    Qt Code:
    1. void MainWindow::on_checkBox_clicked()
    2. {
    3.  
    4. if(ui->checkBox->isChecked())
    5. {
    6. cbx=1;
    7. //Something
    8.  
    9. } if(!ui->checkBox->isChecked()){
    10. QMessageBox::StandardButton reply;
    11. reply = QMessageBox::question(this,"Test", "Do you want to stop logging?", QMessageBox::Yes|QMessageBox::No);
    12. if(reply==QMessageBox::Yes){
    13. // A message should flash saying "Logging is stopped"
    14. qDebug()<< "Logging is stopped";
    15. cbx=0;
    16.  
    17. }else {
    18. qDebug()<<"Logging will continue";
    19. // A message should flash saying "Logging will continue" and Keep the checkBox status back to checked again.
    20.  
    21. }
    22.  
    23. }
    24.  
    25. }
    To copy to clipboard, switch view to plain text mode 

    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.
    Last edited by rookee; 9th December 2015 at 15:52.

  2. #2
    Join Date
    May 2015
    Posts
    66
    Thanks
    10
    Thanked 17 Times in 17 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to check the checkbox based on users selection from a message window.

    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.

  3. The following user says thank you to Vikram.Saralaya for this useful post:

    rookee (9th December 2015)

  4. #3
    Join Date
    Oct 2015
    Posts
    35
    Thanks
    11
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: How to check the checkbox based on users selection from a message window.

    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?

  5. #4
    Join Date
    May 2015
    Posts
    66
    Thanks
    10
    Thanked 17 Times in 17 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to check the checkbox based on users selection from a message window.

    Qt Code:
    1. else {
    2. qDebug()<<"Logging will continue";
    3. ui->checkBox->setChecked(true);
    4. }
    To copy to clipboard, switch view to plain text mode 

  6. #5
    Join Date
    Oct 2015
    Posts
    35
    Thanks
    11
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: How to check the checkbox based on users selection from a message window.

    Thanks a lot Vikram. It's working.

Similar Threads

  1. Replies: 6
    Last Post: 27th October 2015, 12:50
  2. How to present a Qt GUI app window to users???
    By wshn13 in forum Qt Programming
    Replies: 4
    Last Post: 29th August 2011, 09:34
  3. Accessing check state of CheckBox in QTableWidget
    By lnxusr in forum Qt Programming
    Replies: 6
    Last Post: 22nd November 2009, 01:13
  4. Replies: 5
    Last Post: 6th March 2008, 19:04
  5. Replies: 14
    Last Post: 9th November 2006, 08:35

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.