3
votes

I Added some QLabels with different colors to A QGridLayout as Layout of a QWidget, now I have a spacing between each Qlabel to the next and I want to remove it. I tried to set the margin of the Labels to "0" and the Alignment of the GridLayout to "0" but it didnt worked very good. i thought the space is maybe the border of the Labels but i checked. do you have any idea?

2
Look at the docs for the layout itself. There's things with "spacing" in their name at the very top.Mat

2 Answers

3
votes

Didnt belive i missed this :O thank yout Mat the solutions was:

layout->setHorizontalSpacing(0);
layout->setVerticalSpacing(0);

thanks

2
votes

You can try setting the spacing:

layout->setSpacing(0);

If that doesn't do it, you can also try setting the contents margins to zero:

layout->setContentsMargins(0,0,0,0);