What are the properties of the QToolbar style that I can change? - css

I have a QToolbar which I have applied style to:
sMainWindowStyle += "QToolBar::handle { image: url(:/icons/toolbar_handle.png); }\n";
However as well as changing the toolbar's handle I want to change the expand arrow >>
I am unable to find a list of properties, so that I can look up what the toolbar expand arrow is. Does anybody know of a definitive list of style properties in Qt?

You can change the expand button with the following CSS.
QToolButton#qt_toolbar_ext_button
{
qproperty-icon: url(:/path/to/image.png);
}
Unfortunately the best way I know to find out which properties you can set, is to browse through the Qt source code. Some styles can even not support some properties, other styles do.

Related

GTK+3 Treeview expander not visible

I built a GUI with a treeview based on GTK+3. The tree view does currently not show the expander of the treeview. However, I can see that there is some space reserved for the expander as the indentation of the rows is larger if there is one element with a 'subcategory'.
In addition, I figured out, that the expander is shown if I use another GTK style.
Therefore, I tried to change to color of the expander, but it has no effect:
*.view { background-color: ... } changes the background color of the 'buttons' in the tree view. However, the expander is still not visible.
treeview.view.expander { color: ...} does not have any effect at all.
Now, my assumption is that the expander is hidden or has some transparency, but I could not find any option to change it.
Do you have any documentation links that explains exactly which CSS option does have an influence on the treeview or its expander or a hint what could be wrong in the CSS file?
Thanks!
I figured out what the problem is: I am missing the icon used by the treeview expander in /usr/share/icons.
The problem is solved by adding the icons specified in .expander { -gtk-icon-source: -gtk-icontheme("icon"); } to the icon sources in /usr/share/icons or /~.icons.

Qt Designer button image change while keeping windows style?

I can change the image or any other style of a QPushButton in the designer by changing the stylesheet, but any change in the style sheet changes all the other properties.
For instance, when I change the border image everything else is changed and it does not inherit the rest of the properties from the parent (or windows style).
How can I keep the windows style while changing only the image?
From How can I set Styles to a QTabwidget without overwriting existing styles in QT ?:
A style sheet is all or nothing. so if u all apply style sheet, it
might sort of reset the look for some widgets and to fix that, you
must supply a full stylesheet.
The key parts are:
A style sheet is all or nothing.
you must supply a full stylesheet.
You can set an image for the QPushButton from the code or by using QtDesigner like this:
Select the button
In the properties window set the image and the
size (properties icon and iconSize).
Did you try set style to the single push button:
your_push_button_pointer->setStyleSheet(
"QPushButton{background-image: url(:/images/call_up.bmp);}"
"QPushButton:hover{background-image: url(:/images/call_hov.bmp);}"
"QPushButton:pressed{background-image: url(:/images/call_down.bmp);}");

Modify button form in Qt

I'm new on Qt and I'm looking for some way to modify the form of a QPushButton, but I didn't find something on the web.
Is it possible and if so, how can I do this?
Thx
If you want to change how the QPushButton looks, you can use the Qt style sheets. If you want to put an image on the button, you can take advantage of the "background-image" property of the QPushButton
QPushButton
{
background-image: url("alpha.jpg");
}
You can change other properties like "border", "background-color", etc. Your question needs to be more specific as to what visual elements you need. Go through the documentation, it will help you.
One way to go about getting a different for the QPushButton is to make the necessary image available. Get the necessary image and make sure it has a transparent background. Use could use other attributes of QPushButton like, "background-color: transparent" and without any border - "border: none".
Hope it helps!

Dynamically change QStyle at runtime?

I want to tweak the existing style at runtime, specifically QStyle::PM_ToolBarIconSize. Can this be done? As far as I can tell, you can only inherit QStyle and override pixelMetric().
Edit 1: In the specific case of QStyle::PM_ToolBarIconSize, I could use QToolBar::setIconSize, but that would set the icon size for just a single toolbar instance. I want to change the underlying style hint to affect all toolbars everywhere with one fell swoop. And QStyle::PM_ToolBarIconSize may not be the only style I want to tweak, it's just the first one I'm looking at that just so happens to have a "change this instance's icon size" function.
Edit 2: I can't just make a new style subclass because the current style is already a custom style based on style sheets. There are several styles that a user can choose from. I don't want to create a bunch of new styles just so I can tweak a couple of toolbar icon or menu height size settings.
This is the exact purpose of QProxyStyle.
Why not overriding QStyle then? Your subclass would return an icon size (via pixelMetric) which depends on a settable parameter of your QStyle.
As Qt does not have a dynamic QStyle mechanism, it is better to create a new style instance with the changed icon size, then set it to the QApplication, rather than altering the current style.

Flex LinkBar: how to set a selected button's background color?

I was able to set the text color of a selected LinkBar button by "disabledColor" style of LinkBar. Accordingly, I expect to set the background color of the selected button by "backgroundDisabledColor" style, however, it didn't work; and except "backgroundDisabledColor", I didn't see any other style that could possibly achieve this. Please help. Thanks.
The problem is probably that you're setting the style on the LinkBar itself - try setting the LinkBar's linkButtonStyleName style to a different style selector that contains all of the styles you need for your button. You should be able to set the fillColors style of the buttons themselves there - this will change the default look of the button.
If you need to adjust the "selected" color or if you need something more advanced than just skinning the button background you'll need to write a custom skin class. This isn't too difficult - the Button class has a whole set of "Selected" styles - selectedDownSkin, selectedUpSkin, selectedDisabledSkin, etc. IMO the best practice is to set your button skin to a custom skin class that sets the different individual styles based on state.
David Flately illustrates this method here. Check out his source - that should get you what you need. A good book on this topic that has this sort of thing along with lots of other examples is Juan Sanchez and Andy McIntosh's Creating Visual Experiences with Flex 3.0. I can't post a link to it because my reputation isn't high enough here yet, but you can find it on amazon or barnes and noble or any other online bookstore.
FYI - answer here....
http://dezeloper.wordpress.com/2010/02/24/flex-css-linkbar-togglebuttonbar-selected-text-color/
Haha, was looking for same thing, you can see on the source code of LinkBar:
// Hilite the new selection.
child = Button(getChildAt(selectedIndex));
child.enabled = false;
Which is clever!!! Rather than set selected to true, they disable the selected button ... why not ;-( Took me half an hour to understand the Flex team logical ...
eBuildy, Flex Specialists

Resources