Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QT layout tips needed

Tags:

layout

qt

I'm working on a simple board game in qt, and i have some problem with the layout. I have two players, their health is represented with pixmaps, at the bottom of the screen. It looks now something like this:

Layout

Notice, that i would like to keep the health indicators on the opposite sides of the screen, and the button in the middle centered, relative to the screen.

BUT when some of the players loose health, this happens:

Layout messed up

If the drawing were not understandable, here, i took some screens:

enter image description here

So the problem is, that the button in the middle starts shifting to one of the edges of the sreen because of the spacers. I understand why it does it, but i simply can't find a solution.

Please if you have any ideas, how i could make this layout work, help me! Thanks in advance!

like image 311
Balázs Édes Avatar asked Dec 29 '25 01:12

Balázs Édes


2 Answers

Make an empty (fully transparent) health indicator pixmap which has the same size as the heart pixmap. Then you can always place three same size health indicator pixmaps for both players.

You can put a Widget where your health indicator should be, set its sizePolicy to a fixed size, and put your health indicator pixmap inside that widget.

like image 35
vsz Avatar answered Dec 31 '25 18:12

vsz