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]QLabel inside a QGridLayout
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]QLabel inside a QGridLayout

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 4.3k 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.
  • M Offline
    M Offline
    maximus
    wrote on last edited by
    #1

    Hi guys,

    I'm having problem with the auto-sizing of the grid layout.
    I want some of my label to have a "maximum size" so it doesn't appear to big
    the label should re-size smaller or bigger whenever the windows size is changed (default behavior of GridLayout)

    I tried every combination of "size policy" for my QLabel, maximum, fixed, etc. It still take the full size of the image and I can't put a maximum size on it (geometry section is grayed out once in the QGridLayout so I can't play there neither)

    before (correct maximum size) :
    https://www.dropbox.com/s/ou6v43pqbe18168/heart1.png

    after (incorrect size, too big):
    https://www.dropbox.com/s/p2di0dbjnfgym2i/afterHeart.png

    Stylesheet used for setting image on label :
    @#label_23 {
    image: url(:/image/icon/heart1);
    }@


    Free Indoor Cycling Software - https://maximumtrainer.com

    1 Reply Last reply
    0
    • M Offline
      M Offline
      maximus
      wrote on last edited by
      #2

      found a workaround, resizing the image outside of qtcreator to my maximum size.
      Will have to investigate later and learn how QGridLayout works..

      https://www.dropbox.com/s/9w0wv5m42lvi08v/heartGrid1.png


      Free Indoor Cycling Software - https://maximumtrainer.com

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Tabi
        wrote on last edited by
        #3

        you can try setFixedWidth and stretch factor for grid columns along with horizontal size policy of label as fixed/maximum.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          maximus
          wrote on last edited by
          #4

          Thanks for your help.
          I set a column minimum width for some column.

          The problem seem to be with the QLabel, even when they are fixed/maximum on size policy (horizontal), they still take too much horizontal space for some reason.

          Here are the screenshot of the grid:
          https://www.dropbox.com/s/lj8emct35u2uu6z/design1.png
          https://www.dropbox.com/s/z4vvonmhntpydj7/design2.png

          Thank you!


          Free Indoor Cycling Software - https://maximumtrainer.com

          1 Reply Last reply
          0
          • T Offline
            T Offline
            Tabi
            wrote on last edited by
            #5

            Can you paste the piece of code in which you are setting layout options and size policies.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              maximus
              wrote on last edited by
              #6

              I found the problem! I was setting all maximum size policies on the QLabel, but my QGridLayout size was set up too large and nothing could take up all the horizontal extra space. I added horizontal spacer, and every object in the grid take it maximum size now.

              I don't want to touch the code it's all generated with designer :)

              Thanks!


              Free Indoor Cycling Software - https://maximumtrainer.com

              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