Qt Layout problem



  • 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.



  • 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.



  • 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.



  • 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.



  • Hi Gerolf,

    could you explain what exactly you mean by custom positioning?

    Thanks


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.