PDA

View Full Version : QDesktopWidget initialization



drweilert
15th April 2008, 21:28
I am trying to write an application that will use multiple screens, if available. I know how to open windows on target screens, but QApplication::desktop()->numScreens() returns 1, even on a 4 screen setup. In examining the Qt (3 and 4) source code, I see that the private attribute QDesktopWidget::d is only initialized (QDesktopPrivate::init()) in resizeEvent(). I have tried sending a resize event, but no joy.

For now, I will use ScreenCount(QPaintDevice::x11AppDisplay()) to get the number of screens, but I am curious as to how to get the QDesktopWidget::init() method called.

aamer4yu
16th April 2008, 08:58
Am not sure about the number of screens,
but u can try this -
Call a QTimer::singlShot(0,this,initialize()); from the constructor.

In the initialize function try to get the number of screens

MyWindow::initialize()
{
m_no_of_screens = qApp->desktop()->numScreens();
}


see if the value is correct this time.

drweilert
16th April 2008, 14:16
Thanks for the suggestion, but still no luck.

drweilert
17th April 2008, 18:18
Solved. I am using Qt3, and had xinerama support turned on. It evidently conflicted with nvidia driver in "non-twinview" mode. Partial olution is to turn off xinerama. Also had to patch qdesktopwidget_x11.cpp. Looks like they (Trolltech) fixed qdesktopwidget_x11.cpp in Qt4.

razor_cell
8th May 2011, 20:42
I am trying to write an application that will use multiple screens, if available. I know how to open windows on target screens, but QApplication::desktop()->numScreens() returns 1, even on a 4 screen setup. In examining the Qt (3 and 4) source code, I see that the private attribute QDesktopWidget::d is only initialized (QDesktopPrivate::init()) in resizeEvent(). I have tried sending a resize event, but no joy.

For now, I will use ScreenCount(QPaintDevice::x11AppDisplay()) to get the number of screens, but I am curious as to how to get the QDesktopWidget::init() method called.

Hi Dear
Would you tell me how can i affecte a widget to a spesific screen please ?