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. Is a way to don't resize QLabel with QPixmap?
QtWS25 Last Chance

Is a way to don't resize QLabel with QPixmap?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 385 Views
  • 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.
  • T Offline
    T Offline
    TomNow99
    wrote on last edited by
    #1

    Hello,

    I have QGridLayout with 9 QLabels on it. I would like to have the same 9 cell's sizes in this QGridLayout, so I set:

        for(int i=0; i<3;i++)
        {
            grid->setColumnStretch(i,1);
            grid->setRowStretch(i,1);
        }
    

    Now I would like to add QPixmap to one cell ( for example 0,0 ). When I do this I get one big cell (0,0) with QPixmap and 8 smaller.

    What I would like to have:

    whatIwouldLike.png

    What I have now:

    whatIwant.png

    Of course the rest 8 cells are empty.

    When I do the same but with QLabels with no QPixmaps everything is ok.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by
      #2

      The pixmap will change the size hint of the label.
      Just set size policy of both directions to Ignored

      JonBJ 1 Reply Last reply
      3
      • T Offline
        T Offline
        TomNow99
        wrote on last edited by
        #3

        @Bonnie Perfect! Thank you!

        1 Reply Last reply
        0
        • B Bonnie

          The pixmap will change the size hint of the label.
          Just set size policy of both directions to Ignored

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Bonnie said in Is a way to don't resize QLabel with QPixmap?:

          Just set size policy of both directions to Ignored

          I have been using Qt widget size policies for a long time now, and I still don't always get how they do/do not work! Maybe I should be using Ignored more, which I have never touched...

          B 1 Reply Last reply
          0
          • JonBJ JonB

            @Bonnie said in Is a way to don't resize QLabel with QPixmap?:

            Just set size policy of both directions to Ignored

            I have been using Qt widget size policies for a long time now, and I still don't always get how they do/do not work! Maybe I should be using Ignored more, which I have never touched...

            B Offline
            B Offline
            Bonnie
            wrote on last edited by
            #5

            @JonB
            The other values are all related to the size hint.
            So if you don't care about its size hint at all, then you probably should use Ignored.

            1 Reply Last reply
            1

            • Login

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