Force remove all horizontal spacing in Qt - qt

Using Qt, I've set up a main dialog with a horizontal layout. This horizontal layout contains three vertical layouts. I really want all controls in these layouts to butt right up against each other, but I can't get QT to remove all padding and spacing.
I've set the spacing, and padding on all layouts to 0, and I've used CSS to clear all borders, padding, and margins. I still cannot get rid of the darn spacing.
Here's an image of what it looks like:
As far as I can think, those widgets should be pushed up against that red line.

Have you tried
layout->setContentsMargins(0,0,0,0);
... where layout is a pointer to a QVBoxLayout, QHBoxLayout, etc?

For anyone with a similar problem try one of the following
layout->setContentsMargins(0,0,0,0);
layout->setSpacing(0);
layout->setMargin(0);

Related

Buttons alignment does not work in Vaadin v.23

I need to place three buttons at the bottom of my page and I want them to be in the left corner, center and right corner respectively. I did create HorizontalLayout into which I added my button. I am fighting with all kinds of alignments for over three days, but whatever I do, buttons remains in the left corner. Here is my code:
HorizontalLayout bottomLayout = new HorizontalLayout();
bottomLayout.setWidthFull();
bottomLayout.setHeight("82px");
bottomLayout.add(buttonA, buttonB, buttonC);
// bottomLayout.setAlignItems(Alignment.STRETCH);
bottomLayout.setAlignSelf(Alignment.END, buttonC);
bottomLayout.setAlignSelf(Alignment.START, buttonA);
bottomLayout.setAlignSelf(Alignment.CENTER, buttonB);
Please do tell me what I am doing wrong and how to correct it.
Also, all my buttons are 80px high and while first two looks vertically aligned to each other, the third one looks couple pixels higher. How do I align them vertically as well?
What you're looking for is bottomLayout.setJustifyContentMode(JustifyContentMode.BETWEEN);
Explainer:
Layouts are 2-dimensional, so the elements in them can be aligned in two ways: horizontally and vertically.
In CSS FlexBox layout model terminology
justification refers to alignment along the layout's direction (horizontally for horizontal layouts)
alignment refers to "cross-axis" alignment (vertically for horizontal layouts)
So setAlignItems and setAlignSelf both refer to the alignment above, wheras setJustifyContentMode refers to justification above.
I have to admit it's really not the most intuitive API. It is like that because it tries to follow the CSS FlexBox model and terminology.

How can I make a VerticalLayout scrollable using vaadin?

I have a Components which exists as a common layout for all my pages. The layout of this component is as follows (made using paint so please sorry :p):
Right arrows mean that this layout is a HorizontalLayout and down arrows VerticalLayout.
I'm really interested in making bodyContent layout SCROLLABLE. Within this layout I usually introduce lots of UI components (more layouts, text fields, forms, grids...) and sometimes components aren't shown due to the lack of vertical space and the absence of vertical scroll. So is there any way to make bodyContent scrollable (using SCSS/CSS or any other way)?
Thanks in advance.
EDIT:
I've solved this thanks to #JaneVi:
.v-ui > .v-widget {
overflow: visible;
}
Try using Panel within which you can put your bodyContent(vertical layout) using setContent() and can have scroll bars when height of your layout exceeds the panel's height.

How to make a simple top navigation bar wrap gracefully at all screen dimensions with only CSS?

I am trying to do something that should be simple but is apparently not so. I just want to make a simple single line navigation bar using a list tag. Thats fine, I can do it. The problem is making it wrap gracefully and still keep the same layout when it needs to appear over multiple rows due to not enough horizontal browser space.
As I say, I'm using a list tag and I have the ride side border of each LI item with a visible vertical line to make the divider appear. The final item I am not shwoing that with a last-child pseudo class. Its important that the far left and right buttons DON'T have vertical borders. This is clear in the top image.
The UL tag itself also has a top/bottom border line visible and in the first demo in the image you can see this clearly.
So now what happens when the menu bar wraps... well there there are 2 key problems...
1) The main issue is that when the menu wraps I can't think of a way to make the new MIDDLE horizontal line appear [shown in red in the 2nd image]
2) Multiple list items now don't need a right side border value. In the example 2 list items don't need a right side border. This could grow to 3 though for some screen displays.
Does anyone have any ideas for resolving this?
Note that I am trying to make the menu wrap naturally, not at fixed pixel break points as its so unreliable for something like this with different pixel density screens and font zooms in certain browsers.

SCSS & Susy: Makes boxes extend into grid gutters

I have made a grid with the excellent Susy.
I want to add a box the content in my grid. When I do this, everything gets cramped, as the box aligns to the same edge of the grid as the content.
I can add padding to the box and then apply box-sizing: border-box. This removes the 'cramping' but it also causes the content to no longer align to the gird.
What I would really like to do is keep the content aligned to the grid and have the box extend into the gutter. Is there a way to do this with Susy?
I have attached a graphic to demonstrate what I mean:
The best solution currently is to add negative margins equal to your padding.
See: Susy: How to extend content box to cover grid-padding as well?
We've added a more complex version of that same mixin to Susy (here), but it hasn't been released in the gem yet.

QT: Position tabs within QTabBar block

There is a QTabBar element with a vertical size policy which is expanding. I want to make the tabs to be aligned to the bottom of the QTabBar element box, but they are always appearing from the top.
I have tried styling QTabBar and QTabBar::tab with different combinations of vertical-align: bottom, alignment: bottom;, bottom:0; but with zero luck. It seems that the only alignment that actually work is when I align horizontally.
Current results:
The tabs are separated from where the content will go. And before suggesting me to not use an expanding vertical policy. I have to do it like this, I have my reasons.
The widget alignment can be set in the containing layout, and you have to use a non-zero stretch value:
vbox->addWidget(tabBar, 1, Qt::AlignBottom);
vbox->addWidget(otherWidget, 1);
The tab will be correctly aligned, with empty space above it, but that space won't be a part of the QTabBar (the expanding policy will be ignored).
If you need to put something in the space above the QTabBar, you could insert it at the bottom of another intermediary QWidget and insert that widget into the layout instead of the QTabBar.

Resources