Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] How can I change the app resolution
Forum Updated to NodeBB v4.3 + New Features

[Solved] How can I change the app resolution

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    roseicollis
    wrote on 20 Jan 2015, 11:46 last edited by
    #1

    Hi!

    I'm making a new GUI app and I want it to show up with a especific resolution, so when in main.cpp I say w.show() it runs in 550x300. I've tried w.resize() but it just shows a little part of the screen instead of change its resolution so if I put an element like this:

    @

    QRect rec = QApplication::desktop()->screenGeometry();
    int h= rec.height()/8;
    int w= rec.width();

    button->setMinimumSize(w,h); //this button will fit inside the screen with full width
    button->setMaximumSize(w,h);
    

    @

    with the resize I just see a part of the button and I should see it complety.

    Thanks.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 20 Jan 2015, 15:12 last edited by
      #2

      First of all it's not resolution. It's simply size. Resolution is the physical granularity of your display.

      @
      QRect rec = QApplication::desktop()->screenGeometry();
      @
      First of all you should not use that. It doesn't take into account any taskbars or other user specific settings. If anything you should use availableGeometry() instead of screenGeometry(), which gives you the working area on the given screen. Anyway this also doesn't handle well multi-monitor setups, which are very common these days.

      Another thing is do you want the whole window (with the frame) to have specific size or just the client area (the part where widget is drawn)?

      As for the above calculation - if height/8 is, say, 400 and the window size is fixed at 300 then of course it will cut some of it.

      I would suggest to only fix the size of the window with "setFixedSize":http://doc.qt.io/qt-5/qwidget.html#setFixedSize and then use layouts inside to place your widgets (buttons, labels etc.).

      1 Reply Last reply
      0
      • R Offline
        R Offline
        roseicollis
        wrote on 21 Jan 2015, 15:08 last edited by
        #3

        Hi,
        avaibleGeometry() didnt work, just did the same as screenGeometry. So I had to fix is with setFixedSize(),

        thank you.

        1 Reply Last reply
        0

        1/3

        20 Jan 2015, 11:46

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved