Tuesday, April 21, 2015

QMessageBox with a countdown

Ever wanted a QMessageBox that includes a countdown and executes a default action in case the countdown is expired and the user has not done anything? The following is wrapping this functionality in a small subclass.

Thursday, April 16, 2015

Uncheck all buttons of QButtonGroup

Uncheck all buttons in QButtonGroup


A QButtonGroup can be nice e.g. when you have a set of checkable buttons where only one of them should be checked at any given time. You simply add all the button to the button group and set it to be exclusive and everything else will be handled automagically.
However, sometimes it is necessary to be able to uncheck a button (and therefore all the buttons) of a QButtonGroup, which is unfortunately not directly supported. To work around this limitation you need to disable the exclusive property of the button group before unchecking the button and enable it afterwards again.

You can also use this little class, which hides the boilerplate code behind an uncheckButtons() function: