(C++) QDesktopWidget
February 24, 2017 · View on GitHub
(C++)
QDesktopWidget
QDesktopWidget is a Qt class to get information about the screen/monitor.
The code below, similar to How to get the screen size? shows how to use QDesktopWidget to obtain the screen size, like this screenshot (png).
#include <QApplication> #include <QDesktopWidget> #include <QDialog> int main(int argc, char *argv[]) { QApplication a(argc, argv); const QRect sz = QApplication::desktop()->rect(); QString w; w.setNum(sz.width()); QString h; h.setNum(sz.height()); QDialog d; d.setWindowTitle("Screen size: " + w + " x " + h); d.show(); return a.exec(); }