Murphy Randle
Murphy Randle

Reputation: 816

Force remove all horizontal spacing in Qt

Using Qt, I've set up a main dialog with a horizontal layout. This horizontal layout contains three vertical layouts. I really want all controls in these layouts to butt right up against each other, but I can't get QT to remove all padding and spacing.

I've set the spacing, and padding on all layouts to 0, and I've used CSS to clear all borders, padding, and margins. I still cannot get rid of the darn spacing.

Here's an image of what it looks like:
Controls not pushed together.

As far as I can think, those widgets should be pushed up against that red line.

Upvotes: 4

Views: 1607

Answers (2)

James
James

Reputation: 2834

For anyone with a similar problem try one of the following

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

Upvotes: 0

njahnke
njahnke

Reputation: 1387

Have you tried

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

... where layout is a pointer to a QVBoxLayout, QHBoxLayout, etc?

Upvotes: 1

Related Questions