4

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.

3
  • Just thinking out loud: If you have tried everything with the layouts, can you confirm that the widgets themselves don't have borders? In other words the layouts and widgets really are butting against each other, but visually there is a margin internal to the widget. Commented Jun 14, 2012 at 7:08
  • That is a great question. I can get the QPushButtons to bump right up to each other, but the Labels, and the Lists do not. Even when I set their margin, border, and padding to zero with css. Could I be missing something when it comes to removing those borders? Commented Jun 15, 2012 at 0:22
  • Small update, it seems that those borders between the list items goes away when I remove the buttons that I had in the layouts. Maybe the buttons are causing odd padding? Commented Jun 21, 2012 at 4:57

2 Answers 2

1

Have you tried

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

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

Sign up to request clarification or add additional context in comments.

1 Comment

I'm sorry I forgot to mention. I did try that on all three of my layouts, and it had no effect. But maybe I missed something. I'll try one more time. Thank you for taking the time to reply. :)
0

For anyone with a similar problem try one of the following

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.