QGridLayout issue - qt

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.

Related

ios 10 autolayout cellview out of view

New to the auto layout world, i can't seem to right align a table relative to its parent content view in the cell. Left aligning works, but when previewing on smaller screens and when running on 6s, the label is not visible/cut off.
according to this thread, the solution was to make sure the tableview was pinned correctly to the parent view controller (0,0,0,0) - but still did not fix my label.
Any help is appreciated.
First of all, add top, left, right and bottom constraints to your tableView.
Also, your label has x position constraint, but how it should lay according to y coordinate? Add label top or bottom or centerVertically constraint.
And what about your redView? Set the needed constraint to it also.

GridPane cuts off Label when using COMPUTED_SIZE

I have a GridPane displaying descriptive Labels on the left side and content Labels on the right side. I set everything to USE_COMPUTED_SIZE in SceneBuilder and added padding to my elements so they don't stick together too closely. This works well if it wasn't for the fact, that the left-side Labels are cut off, if the content is big enough to take up the whole width of the scene:
Is there a way of making sure that my left-side labels are displayed in full, before the right side labels get their share of available width? Setting the minimum width of the first column to a concrete value works, but i would like JavaFX to determine the needed size for the first column.
Use Texts (can be found in Shapes) instead of Labels in the first column. In contrast to Labels Texts are not resizeable and GridPane cannot resize the first column to become smaller than the largest of the Text nodes in this column.

How to delete the space between QLabel and QLineEdit

I have a QDialog window like this and I want to delete the space between 'Length', 'n', 'm' and corresponding QLineEdit input boxes. How can I achieve that ?
If you use gridlayout, I am not sure why your output looks like that. Generally Qt will not leave huge empty space like that, There are three possibility I can think of:
You have many SPACE after Length:, M: or N:
The layoutHorizontalSpacing is too large in your grid manager.
The layoutColumnStretch was set to in favor of label in your grid manager, should be "0,0", not "1,0". I mean, stretch of Label should not be higher than lineedit.
Still, I would use a simple form layout in your application.
All you need to do is reset the alignment of the labels:
label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlighVCenter)
This can also be done in via the Property Editor in Qt Designer.
You have to decide what to do with the space you want to remove :
Reduce the whole widget : it depends on the surrounding layout, adding an horizontal layout on right or left of it will put the space out of your widget.
Space on the left of your labels : you can align the label text to the right as ekhumoro suggested, or directly reduce and align to the right the whole frame by adding an horizontal spacer on its left (in the surrounding layout).
Space on the right of your line-edits : like above you can add horizontal spacers or reduce and align the frame.
Expand the line-edits : remove their fixed width (default horizontal policy is expanding) or set a bigger one.
The point is : the space has to be somewhere except if you reduce the parent widget or enlarge some the inner widgets. Size-policy is useful to tell which widget should take the available space, spacers are useful to let empty space between widgets.

Qt layout is larger than it should be

I had a layout all nicely designed in Qt, but as soon as I clicked on the parent window and set it to a grid layout, things got all wonky. I've read every tutorial I can find as well as the Qt designer manual and just cannot figure out why this is happening. I have attached a screenshot to show the problem:
As you can see, the vertical layout on the left insists on being wider than the children it contains. Both the label and the treeview are set to sizePolicy maximum, and the maximum width is set to 260px. The children themselves stay the correct size, but the vertical layout that contains them doesn't.
The vertical layout in the middle is set to expanding, and the one on the far right is setup the same as the one on the left, only that one appears to work. How do I make the first vertical layout conform to it's children's width?
Also, if I may sneak a second question in, I have a QTextEdit inside the tab widget in the lower right, but it will not fill to take up the space of the full tab view. You can't see that in the screenshot, but if I pull the tabview up, the textedit within it doesn't stretch with it. How do I make it conform to the size of the tab? It's already set to sizePolicy expanding, but that doesn't seem to help.
The problem is most likely that you need to experiment with "stretching" the layout. Stretch sets the size of layout cells in relation to each other. The default is 0, which means no stretching occurs.
In your case, I believe you want to set the stretch of the first column (column 0) to 0, and the stretch of the second and third columns to 1. This means that the first column will always be as small as possible, and the second and third columns will try to be equally wide.
You can set the stretch programmatically quite easily; for example, to set the first column to stretch 0:
layout->setColumnStretch(0, 0);
In Qt Designer you can access column and row stretches as any normal properties.

How to scale an widget in specified in qt

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.

Resources