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. Qt Layout problem
Forum Updated to NodeBB v4.3 + New Features

Qt Layout problem

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.7k 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.
  • L Offline
    L Offline
    lbolognini
    wrote on last edited by
    #1

    Hi all!

    I have a grid layout with cards like the one below.

    !http://i.imgur.com/7kbsd.png(Qt Layout problem)!

    The cards are implemented as QLabel with a fixed size policy and min and max size specified. The problem is when I click on the 10 of Hearts to play it (and moving it away from that layout), the other two cards are organized to take the whole space leaving an equal margin on their right. I'd like to have these two other cards to stick on their own positions.

    Now there are workarounds. Like I could inject the QPixmap on some empty QLabels but I'd really like to have it working by having the cards stay put on their original position and not aligning on the left of the container layout.

    I'd appreciate anybody pointers to make this work.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      rcari
      wrote on last edited by
      #2

      Maybe you should have 3 static widgets that each contain one QLabel. You should set the fixed size on those widgets so that when you remove one of the QLabels, nothing moves.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lbolognini
        wrote on last edited by
        #3

        Is that the best way there is in Qt? That's the real question.

        Otherwise I could even remove them from the grid layout and place them on the main window at fixed positions. I like working with the layouts as I can addWidget and removeWidget.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          Hi,

          if you want to remove widgets from layouts, the layouts are recalculated, that's how layouts are defined. If you want the widgets to stay in their positions, you need custom positioning or transparent widgets (or spacers) instead.

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lbolognini
            wrote on last edited by
            #5

            Hi Gerolf,

            could you explain what exactly you mean by custom positioning?

            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