Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved How to do with resolution adaptation?

    General and Desktop
    2
    3
    269
    Loading More Posts
    • 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.
    • Limer
      Limer last edited by Limer

      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 Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by 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.

        Limer 1 Reply Last reply Reply Quote 1
        • Limer
          Limer @mrjj last edited by

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

          1 Reply Last reply Reply Quote 0
          • First post
            Last post