I have divided my main screen in 4 areas as border-layout as center,right,left and bottom. The right, left and bottom areas are small and contain only buttons. My center area has to display the different widgets and forms depending on the buttons pressed in right/left/bottom areas.
Can anybody suggest how I can design my forms or widgets so that when I show the widget in the center area, it will fit into the center area and all the items inside this will be scaled rationally.
Please refer to the attached image file for a better idea.
If my explanation is not clear please let me know I will try better.
Looks like you already have a decent start. If you only have icons, typically icons won't be able to expand much so you will want your left,bottom and right containers to be non-expanding.
The center container (most likely a QStackedWidget in your case) will be expanding both horizontally and vertically.
You will also need to add spacers at the bottom of left area and right area.
The bottom area can also use spacers on both sides.
In short
Bottom area: sizePolicy: Preferred/Minimum, maximumSize: inf/40
Left area: sizePolicy: Minimum/Preferred, maximumSize: 40/inf
Right area: sizePolicy: Minimum/Preferred, maximumSize: 40/inf
Center area: sizePolicy: Preferred/Preferred, maximumSize: inf/inf
Here is what you can do with drag and drop within QtDesigner
Here is what it looks like
Here is what it will look like expanded. Notice that although the main area is bigger, the buttons sides remain the same.
Related
I have a Qt Widget which contains two scroll areas vertically. In these scroll areas, labels are dynamically added and the count of labels always changes. Now I am trying to implement a feature where i can drag either the bottom border or top border of the second scroll area so that the view of the dragged border changes. Does anyone know how can this feature be achieved.
UICollectionView's ContentView have two items.
CollectionReusableView.
CollectionViewCell.
here, I want to set CollectionReusableView as header with Vertical Scrolling direction and collectionVeiwCells with Horitontal Scrolling Direction.
how do i make this posible
here,Top View is collectionReusableView and Bellow view is collectionViewCell.
i would like to have horizontal scrolling for CollectionveiwCells alone.
We can't set horizontal and vertical scrolling separately for UICollectionView's cells or collectionReusableViews. It's only possible to set scrolling directions and bounce to UICollectionView class alone.
I have planed to customize UIView with stretch header, for that i have arranged two separate UITableViews with vertical scrolling inside the two collectionViewCells with horizontal scrolling direction respectively. This collectionveiw should be part of UITableViewController with static cells which should have vertical scrolling only. To get more clarity on this please refere the image bellow.
I have a QtGui.QVBoxLayout widget which exists inside a main QtGui.QGridLayout layout, which extends and centers the items all over the place (The left side)
I want the items to get stacked up at the top of the widget (The right side)
How can I achieve this? I know it has something to do with SizeHint, but I'm not sure how to use it.
A QBoxLayout will distribute the widgets evenly over the available space. The easiest way to keep all the widgets packed together at the top of a QVBoxLayout, is to add a stretchable spacing at the bottom that will push all the widgets up.
You can add a stretch that will take up as much space as it can with QBoxLayout::addStretch().
I have a problem with when setting my centralwidget with QGridLayout. I have three widgets in my centralwidget. One is one bar in the top that covers all the horizontal length of the centralwidget and the other two are two frames, one square in the left and other one in the right.
My purpose is that the top bar won't change vertically and the left square can expand both vertical and horizontal, and the right on stays without expansion and always in the right corner of the centralwidget giving the left one space to expand.
The problem is when setting the size policy of the right one. If I put fixed the left one will take all the space.
I don't know if you get the idea. Sorry, this is the best I can explain. I would be very appreciated if you could help me.
I set a max and min length to the right widget and it worked.
I am trying to place a set of buttons so that they are anchored to the bottom right of the screen. My problem is that whenever I resize the screen, the buttons are not anchored to the bottom right, but stay in its current position.
I have placed two Push Buttons inside a Horizontal Layout. I then placed this layout inside a Grid Layout, which contains a Horizontal and Vertical Spacer. I have modified the Grid Layout layoutSize property to SetMaximumSize.
What am I doing incorrectly, so that I can get my buttons to be anchored to the bottom right?
You have almost everything just right here, but you probably overlooked something that is really easy to miss when you first start using Qt Designer.
Your grid layout is sitting inside your widget with a fixed size and position. It too needs to be managed by a layout. If you take a look at the Object Inspector on the top right (that contains your hierarchy) you will probably see your top level widget with a red icon. This indicates that it contains no layout. You have two options to fix this...
Have your existing grid layout placed into another main layout (like a vertical layout). You would simply right click on your top level widget in the Object Inspector -> Lay Out -> [Choose a main layout type].
Have your grid be the main layout. To do this you would need to remove the grid layout and have your child items arranged exactly how you have them in that picture. Then follow the previous option, right clicking on the top level widget (or the blank background) and choose Lay out -> Grid. This will pop your widgets into a Grid at a best visual fit (which you can then fix if needed), and your grid will be the top level layout.
That grid layout will make placing other widgets quite hard. Try this instead:
Add (from left to right) horizontal spacer and the two buttons.
Multiselect them all.
Select "Lay Out Horizontally" (Ctrl-H) from the Qt Designer's (or Qt Creator's) top toolbar (not from the widget box in the left!).
Add vertical spacer on top of the previous widgets.
Select the main window by clicking it (none of the added widgets are now selected).
Select "Lay Out Vertically" (Ctrl-L) from the top toolbar.
Done.
It seems that you're doing it correctly. Just forgot to apply a layout to your central widget, right? The Grid layout should be arranged in your central widget. The more convenient way is to remove grid layout widget and lay out the central widget in a grid ;-)