Results 1 to 3 of 3

Thread: getting Displaysize

  1. #1
    Join Date
    Jun 2010
    Posts
    3

    Default getting Displaysize

    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?

  2. #2
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    1

    Default Re: getting Displaysize

    BTW, I never play with QtOpenGL before. Maybe, you can try the following codes:

    Qt Code:
    1. QGLWidget glWidget;
    2. QSize displaySize = QApplication::desktop()->screenGeometry(&glWidget).size();
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Aug 2012
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: getting Displaysize

    Heres some code I have for this purpose;

    Qt Code:
    1. int resolution1x,resolution1y,resolution2x,resolution2y,resolution3x,resolution3y,NumberOfMonitors;
    2. int totalx, totaly;
    3.  
    4. QRect screenres1,screenres2,screenres3;
    5. QPoint bottomright1, bottomright2,bottomright3;
    6.  
    7. NumberOfMonitors = QApplication::desktop()->screenCount();
    8. std::cout << "The Number of monitors is " << NumberOfMonitors << " \n";
    9. if(NumberOfMonitors == 1){
    10. screenres1 = QApplication::desktop()->screenGeometry(1);
    11. bottomright1 = screenres1.bottomRight();
    12. resolution1x = bottomright1.x();
    13. resolution1y = bottomright1.y();
    14. totalx = resolution1x;
    15. totaly = resolution1y;
    16. }
    17. else if (NumberOfMonitors == 2){
    18. screenres1 = QApplication::desktop()->screenGeometry(1);
    19. screenres2 = QApplication::desktop()->screenGeometry(2);
    20. bottomright1 = screenres1.bottomRight();
    21. bottomright2 = screenres2.bottomRight();
    22. resolution1x = bottomright1.x();
    23. resolution1y = bottomright1.y();
    24. resolution2x = bottomright2.x();
    25. resolution2y = bottomright2.y();
    26. totalx = resolution1x + resolution2x;
    27. totaly = resolution1y + resolution2y;
    28. }
    29. else if (NumberOfMonitors == 2){
    30. screenres1 = QApplication::desktop()->screenGeometry(1);
    31. screenres2 = QApplication::desktop()->screenGeometry(2);
    32. screenres3 = QApplication::desktop()->screenGeometry(3);
    33. bottomright1 = screenres1.bottomRight();
    34. bottomright2 = screenres2.bottomRight();
    35. bottomright3 = screenres3.bottomRight();
    36. resolution1x = bottomright1.x();
    37. resolution1y = bottomright1.y();
    38. resolution2x = bottomright2.x();
    39. resolution2y = bottomright2.y();
    40. resolution3x = bottomright3.x();
    41. resolution3y = bottomright3.y();
    42. totalx = resolution1x + resolution2x + resolution3x;
    43. totaly = resolution1y + resolution2y + resolution3y;
    44. }
    45. else{
    46. screenres1 = QApplication::desktop()->screenGeometry(1);
    47. bottomright1 = screenres1.bottomRight();
    48. resolution1x = bottomright1.x();
    49. resolution1y = bottomright1.y();
    50. totalx = resolution1x;
    51. totaly = resolution1y;
    52. }
    53. std::cout << "The total x pixels are " << totalx << " \n";
    54. std::cout << "The total y pixels are " << totaly << " \n";
    55. std::cout << "And screen 1 has " << resolution1x << " x pixels \n";
    56. std::cout << "And screen 1 has " << resolution1y << " y pixels \n";
    To copy to clipboard, switch view to plain text mode 

    In case this is still useful to anybody

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.