2

I have a Qt application which runs on Ubuntu 12.04 Server with KDE plasma desktop. If I compile with Qt 4.8 full screen works as expected. With Qt 5.3, the window is getting bigger than the available resolution. If I set the resolution using the following code, it works.

QSize sz(QApplication::desktop()->size());
main_window->setFixedSize(sz.width() + 1, sz.height() + 1);
main_window->showFullScreen();

Is this the proper way to solve this issue?

Thanks in advance.

ramtheconqueror
  • 1,907
  • 1
  • 22
  • 35

1 Answers1

1

Qt is quite flexible in application sizing and provides you with a lots of informations (and options).

For what concerns QApplication you can use QDesktopWidget.

QDesktopWidget * screen = QApplication::desktop(); 
screen->availableGeometry();

As stated in the docs about availableGeometry:

Returns the available geometry of the screen with index screen. What is available will be subrect of screenGeometry() based on what the platform decides is available (for example excludes the dock and menu bar on Mac OS X, or the task bar on Windows). The default screen is used if screen is -1.

Read the section "Use of the Primary Screen" in QDesktopWidget docs for details about the "default screen" and the general handling of multiple screens. Using these methods you will have full control over the way your application is laid out, even with multiple screens available.

For what concerns QGuiApplication you can use QScreen:

QScreen * screen = QGuiApplication::primaryScreen();
screen->availableGeometry();

Finally, in QML it is possible (and advisable) to use Screen object which provides Screen.desktopAvailableWidth and Screen.desktopAvailableHeight which ensure proper resizing with different versions of Android/iOS.

BaCaRoZzo
  • 7,502
  • 6
  • 51
  • 82