0
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.

Samuel Harmer
  • 4,264
  • 5
  • 33
  • 67
shan
  • 1,164
  • 4
  • 14
  • 30

2 Answers2

0

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.

Community
  • 1
  • 1
Samuel Harmer
  • 4,264
  • 5
  • 33
  • 67
  • Help me to help you: define "doesn't work". I've just tried this with Qt 4.8 on Ubuntu 10.04 and it sizes the window so it fills up the maximum space available without overlapping the top or bottom panels. If you want something different to this, go back and update your question to ask for **precisely** what you want, with no ambiguity. – Samuel Harmer Apr 05 '12 at 10:57
  • Ok. I'm using Qt 3(see the title). Any way just try this. `resize(dt->size().width()-5, dt->size().height()-5);` this doesn't change the result what you got above. – shan Apr 05 '12 at 11:40
  • Note: My problem is, when i increase the size of a dock area main window gets wider than screen size. i want to prevent it. i'm trying it by implementing `eventFilter()` method. but i'm not getting success... – shan Apr 05 '12 at 11:49
  • `resize(dt->size().width()-5, dt->size().height()-5);` does work, but the window manager clamps it to the available space. But it sounds like this whole question is irrelevant: as your actual problem is how to implement the dock properly so it doesn't expand the width of the main window. – Samuel Harmer Apr 05 '12 at 12:16
0

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

shan
  • 1,164
  • 4
  • 14
  • 30