Solved Too much height around QLabels
-
In QtCreator's form designer I have two sets of QLabels each in their own QVBoxLayout, both QVBoxLayout are in a QHBoxLayout.
I'm trying but failing to reduce the horizontal space between each QLabel, the gap between each line is too great. I've set all QLabels to align to the top, have set spacing and margin to 0 in the QVBoxLayout. In C++ I've set setSizeConstraint to minimum size for the layout which results in T in Token Id disappearing a little as can be seen. Set size policy to minimum for each QLabel with setSizePolicy. Have set margins and padding to 0px in the style sheet for QLabels but still I've got a large gap between lines.
This list of labels should be half the height!
-
@Bushstar
If possible, you could try disable style sheet and see if it then shows at expected. -
Hi
you can use a spacer
Just drag it to the layout in the button and it should compress them. -
Tried that but the result seems to be no better, or not significantly so. Included a screen from the Designer.
The row of buttons at the bottom which were just below the text labels now have a large gap. Need to reduce the height around the QLabel and get that button row to move up.
Everything resides in a QFrame, I'm posting the structure here. I'm new to designing Qt forms, I may be doing something very wrong!
-
Hi
It looks right from looking at it but should compress.Can you post your UI file here so i can have a look at it ?
You can also use
https://paste.ofcode.org/if huge.
-
Here's the UI code. There's a QVBoxLayout under the buttons called token_form, this is where I'll dynamically add forms based on which button is pushed, I added a space under that as well to try and push things up. The UI should end up with two halves, the bottom half beginning at the QLabel Tranaction on the left hand side.
-
Hi
When i run it i get this
So it does seem to keep the label compressed so i wonder if you insert something at runtime that confuses it
or what is going on.Could you run test just to be sure you get same results?
https://www.dropbox.com/s/rfmhywvc4qlc844/testcompress.zip?dl=0 -
It must be inheriting something from the program. I'm adding an extra tab into an existing open source application. I will take a look and see if I can find something that is adding the spacing.
I did define margin and padding 0 in the QLabel styleSheet in the Qt Designer for the page, do you need to specify that the settings in the QLabel override the global style sheet?
-
@Bushstar
Hi
I also wondered if something from stylesheet even im not sure what it could be.- i did define margin and padding 0 in the QLabel styleSheet in the Qt Designer for the page, do you need to specify that the settings in the QLabel override the global style sheet?
Im not 100% sure what you ask. 😋
If the page (widget) has a stylesheet then it should win over any global style sheet you set on QApplication. -
I was thinking of the CSS !important property, could not remember it's name. Will find and check the global style sheet.
-
@Bushstar
If possible, you could try disable style sheet and see if it then shows at expected. -
@mrjj It was the style sheet for the application that was interfering. Giving all elements their own specific name was enough to stop those styles applying to the new widget I was adding.
Thanks for taking the time to help me out with this, it's appreciated.
-
@Bushstar
Good to hear. :)
Thank you for reporting back. It useful to know what was the actual cause.