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. How to do with resolution adaptation?
Forum Updated to NodeBB v4.3 + New Features

How to do with resolution adaptation?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 585 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.
  • LimerL Offline
    LimerL Offline
    Limer
    wrote on last edited by Limer
    #1

    For better layout, I often use plain number to layout, such aslayout->setSpacing(20),font.setPixelSize(12);,etc...(I know setPointSize() can replace setPixelSize() to get better adaptation, here is just a example, ignore it.)

    So, if you use plain numbers to layout your app interface, it will lost it's adaptation.

    I think it deeply for some time, finally find a way: by using resolution proportion.

    for example,

    QSize currentResolution = getResolution();
    double resolutionProportion = currentResolution.width() / 1920.0; // 1920 is the resolution's width of your pc on which develop this app
    ...
    ...
    ...
    layout->setSpacing(20 * resolutionProportion );
    

    Is this a good solution? If not, could you tell me the better or best solution?

    Thanks a lot.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      You are using an int for resolutionProportion so i fear it will be truncated and zero
      for most cases.
      To have effect, i think you need something like

      double resolutionProportion = (double )currentResolution.width() / 1920.0;
      layout->setSpacing( ceil(20 * resolutionProportion ));
      (or floor or round )

      Other than that, i think the idea is fine enough.

      LimerL 1 Reply Last reply
      1
      • mrjjM mrjj

        Hi
        You are using an int for resolutionProportion so i fear it will be truncated and zero
        for most cases.
        To have effect, i think you need something like

        double resolutionProportion = (double )currentResolution.width() / 1920.0;
        layout->setSpacing( ceil(20 * resolutionProportion ));
        (or floor or round )

        Other than that, i think the idea is fine enough.

        LimerL Offline
        LimerL Offline
        Limer
        wrote on last edited by
        #3

        @mrjj Yes, yes....I wrote it wrong, sorry, thanks for your response.

        1 Reply Last reply
        0

        • Login

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