Elide/text-overflow/ellipses text in Webkit - qt

It is possible to configure the QWebView to work with "Elide" disabled (equivalent to Qt::ElideNone)?
The "Elide" graphic texts being compressed (elieded) to fit inside the select.
Example:
I wish the entire text to be displayed when clicked on comobox (selectbox). Is it possible?
Thanks.
[edit]
I think it may be the way the styleSheet (qt):
QComboBox QAbstractItemView {
...
}
I just do not know which property to use styleSheet disable "elited".
Maybe something like this:
QComboBox QAbstractItemView {
elided: none;
...or...
elide: none;
}
Anyone know a link with all properties stylesheets used in QT (I searched but did not find)?
[edit 2]
I tried white-space: pre; and white-space: nowrap; that seems the most logical, but does not work with QAbstractItemView, will be the selector is another?

You can change the textElideMode property by adding a rule QComboBox QAbstractItemView { qproperty-textElideMode: ElideNone } (See Style Sheet Syntax - Setting QObject properties) but it will only clip the text on the right without extending the drop-down box.
According to the code source, the list view adjust its size to its content when it is displayed as a popup which is done by adding this in the stylesheet:
QComboBox {
combobox-popup: true;
// To make room for the possible scrollbar
// (the value has to match the scrollbar width of the current style/platform)
padding-right: 20px;
}
Outside that popup mode, the width of the drop-down box is taken from the list view minimum size (or from the min-width css property of the QAbstractItemView), but there doesn't seem to be a way, with css only, to automatically adjust the size of the drop-down box to the content of the list.

Related

How to hide circle from radio button and only show icon in qt?

I want user to select a theme which he wants to apply to the document.
So i have created a popup dialog which has multiple themes which are qradiobutton. But I want to display only icons and remove circle from the widget.
I have tried visible:hidden for the radio button but that didn't worked.
If you want to customize QRadioButton with style-sheets I suggest you check the reference documentation: https://doc.qt.io/qt-5/stylesheet-reference.html#qradiobutton-widget
You should also find useful the examples given in Qt documentation as it shows how to replace the check indicator by different images:
QRadioButton::indicator {
width: 13px;
height: 13px;
}
QRadioButton::indicator::unchecked {
image: url(:/images/radiobutton_unchecked.png);
}
QRadioButton::indicator:unchecked:hover {
image: url(:/images/radiobutton_unchecked_hover.png);
}
https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qradiobutton
If you do this yo can just use the indicator to display the icon and leave the QRadioButton label empty.
However, I have to warn you, depending on which QStyle you are using, it could happen that using style-sheets destroys completely the style of a component. A general example is: you are using a style where buttons have round corners, you use style-sheets to change the font of the button and as a result the button does not have round corners anymore. This is caused by incompatibilities between some QStyle and the style-sheet mechanism. If you do not want to make a multi platform app, it might not be an issue as you will use only one style, but if you make an multi platform app, you have to check every possible style you platform can have on the different platforms.
So if you want to have a QRadioButton without indicator and not use style-sheets, you can do it in C++ directly by subclassing QAbstractButton. Just make sure you set your class to be autoExclusive so that is will behave like a radio button.
would you try this? ( visible => visibility )
input[type="radio"] {
visibility: hidden;
}
or
input[type="radio"] {
display: none;
}

QScrollArea: How to set the handle size?

I'm designing this for a touchscreen, so the scrollbar handles need to be extra big, but so far, this is all I can get:
In the constructor of the list widget:
myScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
myScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
myScrollArea->verticalScrollBar()->setFixedWidth(pitch_height);
myScrollArea->setWidget(this);
pitch_height is the size of the icons. I figured that'd be about right for the scrollbar too. Something roughly like this:
Use style sheets to modify scroll bar
QScrollBar:vertical {
width: 100px;
}
Relevant documentation:
Customizing QScrollBar
Qt Style Sheets Reference

css ONLY styling checkboxes and radio buttons

I've been themeing a big project lately and I was using icheck.js to style my checkboxes until I realized how slow it reacts to touches.
I realized that the way to go is css styling, however from what I saw, the checkbox needs either to be close or inside the label.
The label of each checkbox has a different width and/or height, and the checkbox needs to be floated right, so the have some variable distance between each other.
Any ideas, or any kind of script that runs super fast in touch devices?
You can do it with HTML / CSS and a bit of JS, but it's a bit tricky, and not very clean.
First of all, you need to wrap your checkboxes with another HTML element (div or whatever) and hide your checkbox element (display: none).
Then, stylise the wrapper element to fit to your custom checkbox, with an unchecked state (as a default) and a checked state (use a class).
Finaly, use a bit of JS to manage clicks to the wrapper element. Working Fiddle, with jQuery (as i'm lazy) :
$('.wrapperCheckbox').click(function () {
var checkbox = $(this).find('input[type="checkbox"]');
var checked;
$(this).toggleClass('checked');
if(checkbox.is(':checked')){
checked = false;
}
else {
checked = true;
}
checkbox.attr('checked', checked);
});
http://jsfiddle.net/49Xg2/2/
As you can see, it's only about plugin the wrapper to its child checkbox and it surely will be lighter than using a lib for this. Note that I didn't test it, so it's probably wrong, but it shows you how to do it.
I know you don't wanna use JS, but you can't get your result only with HTML / CSS 100% working on all major browsers.
the same without java script using just label.
input[type=checkbox] {
display: none;
}
.wrapperCheckbox {
width: 2em;
height: 2em;
background: red;
display:block;
}
input[type=checkbox]:checked + label{
background: blue;
}
http://jsfiddle.net/49Xg2/7/

QT Stylesheet for HLine/VLine color

I'm pretty new to this Qt thing and its whole stylesheet system. My background of HTML/CSS helps a little to understand the system, but a lot of things just happens for no apparent reason....or don't happen.
Anyway, the mystery of the HLINE and the VLINE and how to change the lines' color is just a mystery for me. I learned from other questions and various fora that it's linked to the QFrame elements. And I can change the color of the line if I just use something like
QFrame
{
color: red;
}
But this of course changes the color of tons of other things that uses a QFrame as well. I could of course go into the HLINE element and put color: red; in there and that works fine, but my app requires that I put everything in a single stylesheet that gets loaded into the app. So styling individual elements is not an option.
A solution would look something like
QFrame HLine, QFrame VLine
{
color: red;
}
QFrame[frameShape="4"] /* QFrame::HLine == 0x0004 */
{
color: red;
}
QFrame[frameShape="5"] /* QFrame::VLine == 0x0005 */
{
color: green;
}
HLine and VLine are tricky to style. It's worth taking a look at the "Detailed Description" section of the documentation. For a quick fix, I found that this set of rules allows customizing the appearance of such lines via stylesheet in a reliable and relatively clean manner:
QFrame[frameShape="4"],
QFrame[frameShape="5"]
{
border: none;
background: red;
}
This works regardless of the frameShadow property, which otherwise affects their appearance and the effect of style rules. Keep in mind that the width of the lines are not 1px by default -- this can be changed using the min-width, max-width, min-height or max-height properties, as appropriate.
For a more detailed overview of my findings, read along.
Most QFrames have the QFrame::Plain frameShape by default, but HLine and VLine's default frameShape is QFrame::Sunken. This means that they are not really lines, but thin boxes that contain a mid-line that's used to provide the 3D effect. From the documentation:
The mid-line width specifies the width of an extra line in the middle of the frame, which uses a third color to obtain a special 3D effect. Notice that a mid-line is only drawn for Box, HLine and VLine frames that are raised or sunken.
If you set the frameShape to Plain, this midline is still visible, and can be styled with the color property (note: that's not a background-color or border-color!)
But this doesn't work for a HLine/VLine that's left with the default Sunken appearance. One way to fix this could be to set separate styles for Plain and Sunken QFrames by using attribute selectors with the decimal values of the property enums (which are described in the documentation in hehadecimal), like so:
/* Reference (from doc.qt.io/qt-5/qframe.html#types):
* - frameShape[4] --> QFrame::HLine = 0x0004
* - frameShape[5] --> QFrame::VLine = 0x0005
* - frameShadow[16] --> QFrame::Plain = 0x0010 (default for most widgets)
* - frameShadow[48] --> QFrame::Sunken = 0x0030 (default for HLine/VLine)
*/
QFrame[frameShape="4"][frameShadow="16"],
QFrame[frameShape="5"][frameShadow="16"]
{
...
}
QFrame[frameShape="4"][frameShadow="48"],
QFrame[frameShape="5"][frameShadow="48"]
{
...
}
but since the styles that work for HLine/VLine with QFrame::Sunken also work for those with QFrame::Plain, it's usually a waste to do so. I show them above for educational value only about how to use attribute selectors.
The best approach is to treat the QFrame as the box that it is, and either (1) set border-top or border-right coupled with a max-height: 0px (or max-width for a VLine), to ensure the inside of the box doesn't take up space in the layout; or (2) use a background color coupled with border: none (in which case, max-height/width should be 1 or larger, otherwise the QFrame is invisible). The latter is the solution I'd recommend, as shown in the first code block above.
Hope this helps!
According to QDarkStyleSheet issue, You could use:
QFrame[width="3"], QFrame[height="3]
These selectors, they seem to work cross-platform, and they are unlikely to change.
Probably better than using enum values as ints, as they are likely to change with Qt versions, and line styling are not, as they fulfill certain requirements.
but my app requires that i put everything in a single stylesheet that
gets loaded into the app.
You can use Conflict Resolution. Suppose that you have a QMainWindow object with lots of widgets on it . Set these style sheets for the maindionw style sheet :
QLabel#label{
background-color: rgb(255, 170, 255);
}
QPushButton#pushButton{
color: rgb(0, 0, 255);
}
QFrame#line{
background-color: rgb(0, 170, 255);
}
The first css just changes a QLabel name label on your mainwindow and set its back color to rgb(255, 170, 255). The next will change text color of a QPushButton named pushButton to (0,0,255);. The third one change property of a line.Lines are just a QFrame.
So the solution that I can offer is to place your css in a file and then load this file using QFile and QTextStream and then set the contents of the file for css of your main winodw or main widget using setStyleSheet ( const QString & styleSheet ) function. or If you are using creator just right click on your main window and select change stylesheet and then paste your css. But bear in mind that you should use conflict resolution.
You can leave Qt's hlines and build up your own very easy. For frames you want looks like hline add property "class" as "HLine" (for example), in designer or in c++ code:
frame->setProperty("class", "HLine")
.
Then, you can define in main view's or in global app stylesheet something like this:
QFrame.HLine {
border: none;
border-bottom: 2px solid red;
}
and you will get horizontal two pixels red line.

How can I change the size of a Dojo button without styling the text?

I'm new to Dojo and CSS, so maybe I'm missing something obvious here.
I have a page with several Dijit buttons that are created programmatically, and I want to make one of them bigger- leave the text alone and increase the space between the text and the edge of the button. I don't want to override the CSS for .dijiButtonNode to do so because there are other Dijit buttons the page that shouldn't be altered.
I tried adding this to the widget declaration:
style: { padding: "1em" }
and this:
class: "PaddedButton"
.PaddedButton
{
padding: 1em;
}
but since Dijit buttons are rendered as nested spans it padded the area around the button instead.
The best way to work with CSS is using one of the browser debugging tools (that you should already be using) like Firebug or the Chrome developer tools. You can find an element's DOM node easily with inspect_element and then directly edit its CSS styles until they do what you want. You can also see what CSS rules are active and what are being ignored or overwritten.
I have come up with a working example here:
http://jsfiddle.net/missingno/FrYdx/2/
The important part is the following CSS selector:
.paddedButton.dijitButton .dijitButtonNode {
padding: 1em;
}
This selects any node with class dijitButtonNode that descends from a node that has both of the paddedButton and dijitButton classes. I couldn't do just a .paddedButton .dijitButtonNode because then the rule would end up being cascaded by a more specific selector.

Resources