Anyone can help me on making my mainwindow resizable?
-
you can also use
@mainLayout->setContentsMargins(QMargins(0,0,0,0));@
to remove the space.
-
Your code would be 10x simpler / life would be easy if you used the creator and the interface builder to make your layouts. That way everything is already visually right in front of you, your not creating any layouts from code, and you can test your resizing without having to build your application...Just saying! :)
That the one benefit I find with the interface builder and Qt compared to .net / vb6 / c#, its nice to be able to see all of your stylesheets / layouts before compilation.
-
[quote author="Sam" date="1347552031"]you can also use
@mainLayout->setContentsMargins(QMargins(0,0,0,0));@
to remove the space.[/quote]
You mean:
@createOptionsGroupBox();
createButtonsLayout();
mainLayout = new QVBoxLayout;
mainLayout->setContentsMargins(QMargins(0,0,0,0));
mainLayout->addWidget(optionsGroupBox);
mainLayout->addLayout(buttonsLayout);
QWidget *widget = new QWidget();widget->setLayout(mainLayout); setCentralWidget(widget);@
Nothing changed...
-
[quote author="dvez43" date="1347552995"]Your code would be 10x simpler / life would be easy if you used the creator and the interface builder to make your layouts. That way everything is already visually right in front of you, your not creating any layouts from code, and you can test your resizing without having to build your application...Just saying! :)
That the one benefit I find with the interface builder and Qt compared to .net / vb6 / c#, its nice to be able to see all of your stylesheets / layouts before compilation.[/quote]
what exactly do u mean? if i make it by the designer debug it and resize it is obvious this will happen:
-
Well just use layouts the way you use them in your code already, only interactive via QtDesigner.
see http://doc.qt.nokia.com/4.7-snapshot/designer-layouts.html -
[quote author="DerManu" date="1347562268"]Well just use layouts the way you use them in your code already, only interactive via QtDesigner.
see http://doc.qt.nokia.com/4.7-snapshot/designer-layouts.html[/quote]No it's really a lot more confusing than code.. So anyone can help do this via code?
My problems:- I don't want that empty space i want from it to be sticked
!http://i.imgur.com/JRUft.png(1)!
And no @ mainLayout->setContentsMargins(QMargins(0,0,0,0));@
doesn't work
- as i have said the upper buttons change the page of the stackedwidget.. Well know that i have done it this way everytime it passes from the
@ui->stackedWidget->setCurrentIndex(page_number_here);@
it simply crashes.. i have no idea why this is happening
-
Since you are also using optionsGroupBoxLayout and buttonsLayout so try setting the contentsmargins for both as well
@optionsGroupBoxLayout->setContentsMargins(QMargins(0,0,0,0));
buttonsLayout->setContentsMargins(QMargins(0,0,0,0));@This should work .
-
[quote author="Sam" date="1347609987"]Since you are also using optionsGroupBoxLayout and buttonsLayout so try setting the contentsmargins for both as well
@optionsGroupBoxLayout->setContentsMargins(QMargins(0,0,0,0));
buttonsLayout->setContentsMargins(QMargins(0,0,0,0));@This should work .[/quote]
No it doesn't work! See it yourself...
-
From the documentation Of QGridLayout
bq. QGridLayout also includes two margin widths: the contents margin and the spacing(). The contents margin is the width of the reserved space along each of the QGridLayout's four sides. The spacing() is the width of the automatically allocated spacing between neighboring boxes.
bq. The default contents margin values are provided by the style. The default value Qt styles specify is 9 for child widgets and 11 for windows. The spacing defaults to the same as the margin width for a top-level layout, or to the same as the parent layout.
and QBoxLayout
bq. QBoxLayout also includes two margin widths:
- setContentsMargins() sets the width of the outer border on each side of the widget. This is the width of the reserved space along each of the QBoxLayout's four sides.
- setSpacing() sets the width between neighboring boxes. (You can use addSpacing() to get more space at a particular spot.
bq. The margin default is provided by the style. The default margin most Qt styles specify is 9 for child widgets and 11 for windows. The spacing defaults to the same as the margin width for a top-level layout, or to the same as the parent layout.
So If you are using Qt Designer you can directly select the layout/centralWidget and then set the margins as 0,0,0,0
like :-
!http://imageshack.us/a/img585/5520/captureaq.png(margins)! -
I did it by the designer and my only problems are: http://qt-project.org/forums/viewthread/20353/#97928