How can I set QTabWidget's tab bar's length? - qt

I have been able to resize the QTabWidget's QTabBar size, but the string inside is always limited to a fixed length.
QTabWidget *tabWidget = new QTabWidget;
tabWidget->setStyleSheet("QTabBar::tab { width: 100px; }");
tabWidget->addTab(imagesList, "abcdefghijklmnop");
The string shown is made of the central five/six characters only.
Thank you for any help,
Pietro
References:
Qt Increase QTabWidget's QTabBar size

When you specify the width of the tab using a style sheet as you do, you also make the width of the tab fixed. If the text is wider than the specified width you will only see whatever characters in the middle of the text that fit. Try increasing the tab width to 200px or 300px, or if it is the minimum width of the tab you want to set (and still have it become wider if needed) use the following style sheet:
tabWidget->setStyleSheet("QTabBar::tab { min-width: 100px; }");

Related

Customizing Mat-Select Width - Angular 11

I'm new to Angular/Angular Material so I'm not sure if this is code I need to write myself or its already built in a specific way. I'm having a problem with the drop down of the mat-select, the panel that pops up when you click select is not matching the width of the select drop down bar with the arrow. I learned from this question: Styling mat-select in Angular Material that the width of the panel is always equal to the width of the select element, but thats not the case for me. Is there a way to fix the width of the drop down if its not the same size?
That depends on the width of the text options you have on your mat-options.
The panel always takes the width of the max text length. so if the max text length is > select input element width, then the panel should be > select element width.
To better understand:
-Example with: max text width < select element width: https://stackblitz.com/angular/olkexjgqxpk?file=src%2Fapp%2Fselect-custom-trigger-example.ts
-Example with max text width > select element width: https://stackblitz.com/edit/angular-4bk5ns?file=src%2Fapp%2Fselect-custom-trigger-example.html
I add the following two rules to my top level style sheet so I never have to deal with the overflow in my select list
.cdk-overlay-pane {
width: fit-content !important;
}
.mat-select-panel {
max-width: unset !important;
}
https://stackblitz.com/edit/angular-pqtiem?file=src%2Fstyles.scss

Inline image height equal to font height

I have an image that represents my email address. I want that this image has the same height as font height or line height. So I tried this:
img.address { height: 1em; width: auto }
<p>My e-mail address is <img class="address" height="15" width="149" src="address.png" alt="[]" />.</p>
It seems to work for Chrome on desktop, but for Chrome on smartphone image is much smaller than the font. I don't understand why? Is there any remedy for that?
NOTE: since this method works for desktop browser, the question could be rephrased like this: why is in smartphone browsers the height of the font not 1em and how can one obtain the height of the font?
EDIT: I added few commands around the image to put it into the context.
The default font-size for a webpage is 16px (reference) where no more setting is applied on document. You didn't set any font size to your html or body or paragraphs and so:
the browser renders image by default font-size (16px) because there
is no more setting to control images size.
Text of webpage may not use default 16px for many other overriding settings as well as android initial settings, accessibility options, mobile friendly standards to render texts etc.
So you have to define your desired font size for entire document and then the texts and images height will have same reference.
Finally if you dont want to set initial font size, a javascript trick is to calculate the height of rendered lines and set it as image height. For example I suggest to extract first word from text and put it into a temporary div and after calculating the height of that div, set it as image height:
var myhtml=$('#imageId').parent().text();
var mywords=myhtml.split(" ");
var fisrtWord=mywords[0];
$(body).append('<div id="tempdiv">' + firstword + '</div>');
$('#imageId').height($('#tempdiv').heigh());
$('#tempdiv').remove();
Final note: the height of lines is about 1.5 times taller than the characters height. So you may reduce the calculated height by 1.5 to have better result.
Actually it is the image that is too small on the mobile. Also, 1em is
supposed to be the font height. This is what makes this problem really
mysterious.
Well not really. font-size: 16px; does not equal to height: 16px;. line-height: 16px; will not either, it actually "just" adds space on top and bottom of the chars. The font-size actually is the width of the widest character in the alphabet (I think it actually measure the letter M). So the thing you are trying to do won't work. Then there is the fact that you would have to cut the image exactly with no space, meaning there is a possible error source there. You would have to try to set the height manually by measure and compare in different viewports. If you give me a hint of what you are trying to do with a screen or something I could possibly present you a other solution. Is there a reason why you want to use a image for your email and not a regular html?

How to change the size of a QScrollBar's arrows?

Some time ago I posted this question trying to understand how could I change the size of a QScrollBar. I was able, at the end, to do what I wanted with the stylesheet code:
setStyleSheet("QScrollBar:vertical { width: 30px; };");
The problem is that, although the width of the scroll bar do change with the code above, the height of the up and down arrow widgets continues to be the same; they don't adjust automatically with the increase in width. So what I get now are two very flat up and down buttons in a large scroll bar.
Unfortunately I wasn't able to even "grasp" the arrow widgets, nor I know what would be the stylesheet code to control just them. The closest I got was from this SO question, but they don't apply to the vertical scroll bar.
So my question is: how can I change the size (particularly the height) of a (vertical) QScrollBar's arrow buttons? (note: no the arrow itself, but the normally square button that contains it)
The Desktop theme specifies the height of these buttons. To have them scaling proportionally you have to remove the styling by setting a background color:
QScrollBar:vertical {
width: 30px;
background: red;
}

how expend horizontally an absolute div still 400px and then add line-break

I want to use this css for tooltip: enter link description here but i want that the hint have a max width of 400px. if i set max-width:400px and remove white-space:nowrap then the width will be always very short (their is a line break on every word). how to specify that the hint can expend horizontally still 400px and then only add line break ?
There are two possible solutions for this. The first is to add the following to ".hint:after, [data-hint]:after"
width: 100%;
max-width: 400px;
As you already surmised, you must remove the "whitespace: nowrap" as well
If for some reason you can't do that, you can also set the "display" property to "table".

gwt tablayout hides the tabs when increasing padding, font, margin

I have created the TabLayoutPanel. If its
.gwt-TabLayoutPanel .gwt-TabLayoutPanelTabInner
CSS Class is modified with padding, say
padding: 15px; or font-size: 25px;
then, the tabs hide with in the browser window. What is the reason and how to fix this?
Thanks,
Bennet.
Just a guess (without seeing any code) but I bet you haven't added your TabLayoutPanel properly. The "Layout" panels are great but you you have to play by the rules.
Make sure that you have an unbroken link of "layout" type panels all the way down to the "RootLayoutPanel".
Also, verify that you are in fact using the "RootLayoutPanel" and NOT the "RootPanel" to add your gwt widget to the dom
RootLayoutPanel.get().add(myTabLayoutPanel);
See here, specifically the section titled "RequiresResize" and "ProvidesResize"
http://www.gwtproject.org/doc/latest/DevGuideUiPanels.html#LayoutPanels
.gwt-TabLayoutPanelTabInner is the wrapper around the label displayed in the actual tab. When you try to increase the padding (say padding : 'z'px;)what happens is it pushes the label by 'z' pixels from all sides and it eventually hides behind the enclosing div or the .gwt-TabLayoutPanel .gwt-TabLayoutPanelTabs.
As a solution you can either adjust the padding so that it doesn't hide behind the parent div or increase the size of parent so as to allow the tabs take more padding.

Resources