Results 1 to 7 of 7

Thread: Need don't show this message again check box in QMessageBox with YesNo button

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2012
    Location
    India.
    Posts
    88
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 8 Times in 8 Posts

    Default Need don't show this message again check box in QMessageBox with YesNo button

    Dear All,
    I want to have "Don't show this message again" check box in QMessageBox with Yes & No buttons , is there a way in Qt to achieve it ?
    I know there is QErrorMessage which gives this check box but I also need yes no button.

    Please help.

    Thank you,
    With Best Regards,
    Last edited by Rajesh.Rathod; 25th June 2014 at 07:17. Reason: updated contents

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    520
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 77 Times in 75 Posts

    Default Re: Need don't show this message again check box in QMessageBox with YesNo button

    Hi, ugly hack:
    you can derive a class from QMessageBox, and if you look at the Qt sources you can see that QMessageBox uses a QGridLayout internally (at least in Qt4). You can get this using layout (), and then add a widget like a checkbox to it.

    This depends on Qt internals, so maybe/probably there is a better way to do it.

    Ginsengelf

    edit: of course you could just create a custom dialog for this...

  3. #3
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanked 342 Times in 324 Posts

    Default Re: Need don't show this message again check box in QMessageBox with YesNo button

    Since Qt 5.2, QMessageBox supports setting custom check box with QMessageBox::setCheckBox method. If you are using older version, you will have to create a custom widget yourself.

  4. #4
    Join Date
    Apr 2012
    Location
    India.
    Posts
    88
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 8 Times in 8 Posts

    Default Re: Need don't show this message again check box in QMessageBox with YesNo button

    Dear All,
    Thank you very much for you help, I am using Qt 4.7.3 so can't use the latest API.

    Actaully, I found a workaround here...

    Qt Code:
    1. QMessageBox msgBox;
    2. QCheckBox dontShowCheckBox("don't show this message again");
    3. msgBox.addButton(&dontShowCheckBox, QMessageBox::ActionRole);
    To copy to clipboard, switch view to plain text mode 

    This seems to work for me, of course I need to connect signal slot and then I need to maintain it's checked state somewhere in my application....

    Thank you.

Similar Threads

  1. How to add a a Button to a QMessageBox?
    By Bong.Da.City in forum Newbie
    Replies: 5
    Last Post: 29th August 2010, 21:02
  2. Check if there is message handler
    By Althor in forum Newbie
    Replies: 3
    Last Post: 14th July 2010, 16:02
  3. Replies: 4
    Last Post: 12th October 2008, 14:47
  4. StatusBar show message
    By Pang in forum Qt Programming
    Replies: 3
    Last Post: 23rd August 2007, 11:22
  5. get button on QMessageBox
    By manhds in forum Qt Programming
    Replies: 3
    Last Post: 27th June 2006, 05:38

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
  •  
Qt is a trademark of The Qt Company.