PDA

View Full Version : adding minimize pushbutton to Hboxlayout



sudhansu
25th February 2010, 13:20
Hi All,
I've a hboxlayout. i need to add a pushbutton in the right side border centre of layout. so that if i press that button i can minimize the treewidget. How to added the button. Herewith i've attached the diagram.

Thank you all.

BalaQT
25th February 2010, 13:35
Just add a pushbutton and dont add pushbutton in layout.
set the parent property and geometry.
ex


QPushButton *btnOk=new QPushButton(this);
btnOk->setGeometry(0,0,100,50);
0,0 is the x,y pos
100,50 is the width and height

syntax : btn->setGeometry(x,y,w,h);

hope it helps

Bala

sudhansu
26th February 2010, 03:11
Just add a pushbutton and dont add pushbutton in layout.
set the parent property and geometry.
ex


QPushButton *btnOk=new QPushButton(this);
btnOk->setGeometry(0,0,100,50);
0,0 is the x,y pos
100,50 is the width and height

syntax : btn->setGeometry(x,y,w,h);

hope it helps

Bala

No it didn't help. ANy other way to do it??

BalaQT
26th February 2010, 05:31
if u dont mind, can u pls tell why its not working ?

i hav done a small example for ur need.
i attached it here.
pls refer the attachment,

pls workaround with ur window positions.

hope it helps
Bala

BalaQT
26th February 2010, 08:19
Other ways

way 1)
To do it by adding spacer.

way 2)
using layouts also we can achieve the same
let the tabwidget is in a Vertical layout.
then add a child Horizontal layout.
add the tabwidget
then add the pushbutton
then add the Horizontal layout into Vertical layout.

i hav attached the example using layout
pls check

Bala