PDA

View Full Version : getting Displaysize



fi0r
30th July 2010, 22:01
hi,

i want to set a QGL Widget to fullscreen. To do that im using

QApplication::desktop()->size()

It works fine with one display but when im using a second display i get the size of both displays. (It still works when i'm cloning my first display)

how do i get the size of the display my application is running on?

saa7_go
31st July 2010, 06:55
BTW, I never play with QtOpenGL before. Maybe, you can try the following codes:



QGLWidget glWidget;
QSize displaySize = QApplication::desktop()->screenGeometry(&glWidget).size();

rdockterjr
22nd August 2012, 18:11
Heres some code I have for this purpose;



int resolution1x,resolution1y,resolution2x,resolution2 y,resolution3x,resolution3y,NumberOfMonitors;
int totalx, totaly;

QRect screenres1,screenres2,screenres3;
QPoint bottomright1, bottomright2,bottomright3;

NumberOfMonitors = QApplication::desktop()->screenCount();
std::cout << "The Number of monitors is " << NumberOfMonitors << " \n";
if(NumberOfMonitors == 1){
screenres1 = QApplication::desktop()->screenGeometry(1);
bottomright1 = screenres1.bottomRight();
resolution1x = bottomright1.x();
resolution1y = bottomright1.y();
totalx = resolution1x;
totaly = resolution1y;
}
else if (NumberOfMonitors == 2){
screenres1 = QApplication::desktop()->screenGeometry(1);
screenres2 = QApplication::desktop()->screenGeometry(2);
bottomright1 = screenres1.bottomRight();
bottomright2 = screenres2.bottomRight();
resolution1x = bottomright1.x();
resolution1y = bottomright1.y();
resolution2x = bottomright2.x();
resolution2y = bottomright2.y();
totalx = resolution1x + resolution2x;
totaly = resolution1y + resolution2y;
}
else if (NumberOfMonitors == 2){
screenres1 = QApplication::desktop()->screenGeometry(1);
screenres2 = QApplication::desktop()->screenGeometry(2);
screenres3 = QApplication::desktop()->screenGeometry(3);
bottomright1 = screenres1.bottomRight();
bottomright2 = screenres2.bottomRight();
bottomright3 = screenres3.bottomRight();
resolution1x = bottomright1.x();
resolution1y = bottomright1.y();
resolution2x = bottomright2.x();
resolution2y = bottomright2.y();
resolution3x = bottomright3.x();
resolution3y = bottomright3.y();
totalx = resolution1x + resolution2x + resolution3x;
totaly = resolution1y + resolution2y + resolution3y;
}
else{
screenres1 = QApplication::desktop()->screenGeometry(1);
bottomright1 = screenres1.bottomRight();
resolution1x = bottomright1.x();
resolution1y = bottomright1.y();
totalx = resolution1x;
totaly = resolution1y;
}
std::cout << "The total x pixels are " << totalx << " \n";
std::cout << "The total y pixels are " << totaly << " \n";
std::cout << "And screen 1 has " << resolution1x << " x pixels \n";
std::cout << "And screen 1 has " << resolution1y << " y pixels \n";


In case this is still useful to anybody