Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) Qt 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();
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict