PDA

View Full Version : Remove space in VBoxLayout



Troebadoer
1st June 2011, 12:30
Hello

For some reason when I drop (using QT Creator) a PushButton onto the VBoxLayout it is not possible to set the height of the PushButton any more. It is important that I can set the height of the button though for ease of use.

I reverted back to creating the form and widgets in code. Here it is possible for me to set the height of the button before adding the button to the layout. The issue now though is that there is a big space between widgets. How can I remove the space between widgets.

I make use of the layout widget because it strecthes the button widgets nicely when the mobile device is tilted. Is there perhaps a different way to keep the buttons stretched in vertical and horizontal mode without using a layout?

Regards

George

Santosh Reddy
2nd June 2011, 05:18
For some reason when I drop (using QT Creator) a PushButton onto the VBoxLayout it is not possible to set the height of the PushButton any more. It is important that I can set the height of the button though for ease of use.
You should be able to set the height from the property editor, what happens if you set from property editor?


I reverted back to creating the form and widgets in code. Here it is possible for me to set the height of the button before adding the button to the layout. The issue now though is that there is a big space between widgets. How can I remove the space between widgets.
You can do this by using a container layout, something like this

QWidget* widget = new QWidget(this);
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addStretch();
layout->addWidget(new QPushButton("Upper"));
layout->addWidget(new QPushButton("Lower"));
layout->addStretch();
widget->setLayout(layout);


I make use of the layout widget because it strecthes the button widgets nicely when the mobile device is tilted. Is there perhaps a different way to keep the buttons stretched in vertical and horizontal mode without using a layout?
You may need to implement your own custom layout management which monitors the device size, and the resize your buttons, I would prefer to use a layout to do this.