I've got a problem. I need to change screen resolution inside of my QT Project(like in some games for example). I have heard that I need to use Windows API, like following:
DEVMODE devmode;
devmode.dmPelsWidth = 1024;
devmode.dmPelsHeight = 768;
devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
devmode.dmSize = sizeof(DEVMODE);
long result = ChangeDisplaySettings(&devmode, 0);
qDebug() << "RESULT OF CHANGE DISPLAY :"<< result;
But Qt says: "'DEVMODE': undeclared identifier". How can I fix it? Maybe I need to include some libraries?
You have to include windows.h header. Here is an working example.
#include <stdio.h>
#include <windows.h>
#include <winuser.h>
int main() {
DEVMODE devmode;
devmode.dmPelsWidth = 1024;
devmode.dmPelsHeight = 768;
devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
devmode.dmSize = sizeof(DEVMODE);
long result = ChangeDisplaySettings(&devmode, 0);
return 0;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.