QFrame Sizing
-
-
Hi
If u used layouts, then it should follow main window?
OR in what way does it not work?Main window is special, so normally u insert a Central Widget, give it layout
then insert all widget there. (into layout of central) -
well just like u did now?
So you have
Central widget ( just a dummy qwidget)
Layout for central
your master widget , (the one seen on picture)
containing all your widget as seen on picture.If you need layout in layout, you can always
insert Qwidget and use as place holder for other type of layout. -
Actually I have added widgets in different layouts and added these layouts in to different frames which I placed in the UI file. This might be the reason they are not extending to the end of the window. Any solution to set the frame size. (i have used only sizepolicy for each frame)
-
Hi
It sounds like u just need one extra layout to follow main win but talking about
layouts is near to impossible.
Also if any of the QFrames are
just free floating then it wont scale.You can set min and max sizes on QFrames to adjust how they scale/resize.
I need your project if to look at it. it not feasible to talk about as I have no idea what u put where etc.
-
Mainwindow.cpp file
QHBoxLayout *upperBarLayout = new QHBoxLayout; QVBoxLayout *sideBarLayout = new QVBoxLayout; QGridLayout *centralLayout = new QGridLayout; QGridLayout *bottomLayout = new QGridLayout(); upperBarLayout->addWidget(widgetA); upperBarLayout->addWidget(widgetB); upperBarLayout->addWidget(widgetC); ui->topframe->setLayout(upperBarLayout); ui->topframe->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); //sidebar sideBarLayout->addWidget(widgetD,Qt::AlignTop); sideBarLayout->addWidget(widgetE,Qt::AlignTop); ui->sideframe->setLayout(sideBarLayout); ui->sideframe->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); //center frame centralLayout->addWidget(widgetF); ui->mainframe->setLayout(centralLayout); ui->mainframe->setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Fixed); //bottom bottomLayout->addWidget(WidgetG); ui->bottomframe->setLayout(bottomLayout); ui->bottomframe->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
The bottom frame is below the central frame. Hope this gives a better idea of my problem.
-
hmm
centralLayout->addWidget(widgetF);
ui->mainframe->setLayout(centralLayout);so widgetF should follow main win. ?
but it seems not all is inside widgetF .
so ui->topframe is not inside Central ?Why didnt you make all in UI editor?
That way u can see at once if working. -
Thanks!! I have solved my problem by removing the frames and putting only layouts. Initially, the main window loads as I want with some space for another widget. I load a widget to this space through a slot then the entire window gets distorted. How to get it back to the original look? Is there a repaint function?
-
@saitej
Hi
the layout will repaint them self if you add widgets.If it becomes "strange" when you insert, its most likely
due to the layout altering the layout.'
Layout alter and controls the size of widgets so it might be some
side effect of you inserting.