Question

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

The documentation says,

What is available will be subrect of screenGeometry() based on what the platform decides is available (for example excludes the Dock and Menubar on Mac OS X, or the taskbar on Windows).

What I want to know is how can I get the available screen geometry (without panels) on Linux? I tried above code on Linux, but it returns physical screen size.

Was it helpful?

Solution 2

For most of the cases availableGeometry() works. I'm using virtual screen. Sometimes it doesn't work properly.

OTHER TIPS

This question implies that calling QApplication::desktop()->size() will give you the size of the desktop on Linux without the panels.

// called from inside the MainWindow constructor
QDesktopWidget* dt(QApplication::desktop());
this->resize(dt->size()); 

This code correctly resizes the main window to fill up the space inbetween the top and bottom bars on Ubuntu 10.04 with Qt 4.8. I can't see any difference in the documentation between Qt3 and Qt 4.8 which suggests the behaviour of these functions has changed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top