PDA

View Full Version : moving widget to Right using QSpacerItem



uz_qt
1st October 2013, 11:12
Hello,

Please have a look at the screen shot attached. I would like to move the graph to right (next to the widget behind the graph). There two widgets are independent and have seperate layouts.
I have used QSpacerItem to the grid layout and I got space to the right of the graph. I want spacing to be added from its left so that it is placed next to the widget behind it.

I have written the following lines to produce the screen shot attached:


QVBoxLayout *MainLayout = new QVBoxLayout(this);
QGridLayout *GridLayoutM = new QGridLayout();

mPlotPost = new PlotPost(this); //widget containing the graph
GridLayoutM->addWidget(mPlotPost);
GridLayoutM->addItem( new QSpacerItem(1,1,QSizePolicy::Expanding, QSizePolicy::Expanding), 2, 6);
MainLayout->addLayout(GridLayoutM);

I have tried changing the coordinates in QSpacerItem, but the spacing does not change as desired.
I have also tried addStrech() method by using QHBoxLayout, but even that adds space from right side!
9658
Please help.

ChrisW67
2nd October 2013, 05:35
Fix your attachment. Cannot see what you mean.