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. Correct dimension of widgets

Correct dimension of widgets

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 367 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.
  • S Offline
    S Offline
    Stefanoxjx
    wrote on last edited by
    #1

    Hi, how can I view a widget with correct size?
    I try to explain...
    I've a QLineEdit with maxLength of 40 characters.
    This QLineEdit is in a Layout.
    When I run my program, I see QLineEdit very short compared to the 40 characters it should contain.
    I tried to set a minimum Width size (setMinimumWidth), but I don't think that this is the correct way.
    Thanks.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Stefanoxjx said in Correct dimension of widgets:

      I tried to set a minimum Width size (setMinimumWidth), but I don't think that this is the correct way.

      It is.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3
      • S Offline
        S Offline
        Stefanoxjx
        wrote on last edited by
        #3

        Really?
        But exist a method to calculate the correct size?

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Stefanoxjx said in Correct dimension of widgets:

          But exist a method to calculate the correct size?

          Yes, QFontMetrics can give you the width of a QString which you can take as a starting point for the needed width.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          3
          • S Offline
            S Offline
            Stefanoxjx
            wrote on last edited by
            #5

            It works fine.
            Many thanks.

            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