PDA

View Full Version : Desktop Dual Screen in Ubuntu 10.04, get screen width and height not coherent.



toglia3d
11th June 2010, 00:33
I'm using official nvidia drivers with twin view and I noticed sizes are not right.


QDesktopWidget desktop;
int w0 = desktop.screen(0)->width();
int h0 = desktop.screen(0)->height();
int w1 = desktop.screen(1)->width();
int h1 = desktop.screen(1)->height();

std::cout << desktop.numScreens() << std::endl;
std::cout << w0 << " : " << h0 << std::endl;
std::cout << w1 << " : " << h1 << std::endl;

output:
2
3600 : 1200
3600 : 1200

My monitor configuration is 1920 1200 and 1680 1050. Obviously the sizes are merged. Is this a normal behavior? How can I get independent sizes?

This is somewhat of a problem since I wanted to fit the window in the center on the first screen...

Thanks

ComaWhite
11th June 2010, 01:23
This works for me and I'm using dual monitors.



#include <QtCore/QtCore>
#include <QtGui/QtGui>

int main(int argc, char** argv)
{
new QApplication(argc, argv);

QDesktopWidget desktop;
for (int i = 0; i < desktop.screenCount(); ++i) {
qDebug() << "Width: " << desktop.screenGeometry(i).width();
qDebug() << "Height: " << desktop.screenGeometry(i).height();
}

return QApplication::exec();
}

toglia3d
11th June 2010, 07:23
Right on the spot. Thanks.