Set windows background using QT

From QT Wikipedia

Jump to: navigation, search

I will suply simple QT example how to set your windows background. So sample CPP code is below:

 
//Some windows headers
#include <stdio.h>
#include <windows.h>
 
//Read currect windows background image path
QSettings appSettings( "HKEY_CURRENT_USER\\Control Panel\\Desktop", QSettings::NativeFormat);
QString dispName = appSettings.value("Wallpaper").toString(); 
 
//Set new background path
appSettings.setValue("Wallpaper", bgpath);
QByteArray ba = bgpath.toLatin1();
SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, (void*)ba.data(),	SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE); //Notification to windows renew desktop
 

Personal tools
Toolbox