PDA

View Full Version : Layout without margin??



zlosynus
2nd August 2008, 09:13
Hi,

when I wrote following simple code:


QPushButton button("Button");
button.show();

it creates me window with button without any margins around.

But when I want to create window with two buttons, so I wrote following code:


QWidget mainwindow;
QHBoxLayout layout;
QPushButton button1("Button A");
QPushButton button2("Button B");
layout.addWidget(&button1);
layout.addWidget(&button2);
mainwindow.setLayout(&layout);
mainwindow.show();

But it creates me margin around both buttons and I really dont want it at all.

jpn
2nd August 2008, 09:59
layout.setMargin(0); // margin of the layout
layout.setSpacing(0); // spacing between items

If you're using Qt 4.3 or later, you may also use:


layout.setContentsMargins(left, top, right, bottom);