Monday, May 10, 2010

Windows 7 or Vista UAC Shield Icon in Qt

(For a way to embed an application manifest with QtCreator see here)

In a Qt application you cannot use the BCM_SETSHIELD message to show the UAC shield icon on a QWidget. This is because Qt does its own painting. The good news is that, it is very simple to access this icon in Qt.

QIcon icon = QApplication::style()->standardIcon(QStyle::SP_VistaShield);

The above code will return null icon on systems older then Windows Vista.
If you are developing for Windows 7 then check out Q7Goodies - a Qt add-on that provides Windows 7 features like jump list, taskbar thumbnails, thumbnail toolbar and more in a Qt way. It integrates seamlessly with existing applications by using Qt design patterns and API style. It comes with the full source code and a royalty-free license.