QToolBar: styling 'show more' button - qt

Does anyone have idea on how to style this rectangular button -which is a default child of a QToolbar?
First two images show the button when the graphical interface is on normal screen mode. It appears; since toolbar icons don't have enough space. Third picture shows fullscreen mode, in which my icons have space.
I want to style its shape, so that it has a radial border, without a corner. This will cancel its ugly look, in second image.
I want to let users use the interface in normal view, so locking application to fullscreen is not an option. I do want to use the button, so removing is not acceptable. Styling its position to 5 pixels left or replacing it with another stylable button could be possible solutions, but I couldn't manage to do them.
I played a lot with toolbutton and pushbutton stylesheets, but had no luck on styling this small button. I am pretty obsessed about my graphical design, but don't want to waste too much time (if solution is not trivial, I will change my toolbar to a rectangular one).
Thanks in advance.

I found the solution by listing the children object names of my toolbar.
QStringList list;
for(int i=0; i<toolBar->children()->size(); i++)
list.append(toolBar->children()[i]->objectName();
Inside the list, there is only one object that has a default name (not " "). It is qt_toolbar_ext_button
Then I was able to style it as:
"#qt_toolbar_ext_button { //... }"

I know this has been answered, but for anyone who needs to know the answer its a "QToolButton" and if you need to style a specific button with an object name you do "QToolButton#objectName" in an external resources file stylesheet or in the Widget UI stylesheet dialog for different objects.
QToolButton#objectName {
}
Check out the documentation - http://doc.qt.digia.com/4.2/stylesheet.html
This gives you the syntax for stylesheets in Qt, or "QSS" files.

Just do it: Qt documentation about stylesheets

Related

Custom shaped menu with shadow in Qt

I'd like to create a context menu looking similar to this one:
I read suggestions on the web that QWidget::setMask() should be used to create a shape. But how can it fit the variable number of items then? Moreover, the same menu item may take more or less screen space on different machines.
Another question is how to create a shadow around this custom shape? As far as I understand, the mask allows to crop the widget, but not to make it semi-transparent.
I don’t found an easy way to do that! But here goes a way!
Instead of using the Qt mask API, I've used a frame-less widget with transparency enabled!
To draw the shadow, I've used radial gradient!
You can change the size of the menu before opening it, however you can’t resize it after opened (for example resize with mouse).
It’s quite easy add or remove widgets, just respect the layout margin to not draw outside the bounds destined to widgets. To simplify your life I created an inherited class of QPushButton with colors you can easily customize with style sheet.
See the result:
You can browse the source
Hope that helps!

Eclipse Neon: unable to hide min/max button row in split pane editor layout

Getting started with Eclipse Neon.
Pleasantly surprised to see that we can now recapture nearly all wasted space from the UI with little effort.
For example, Gtk 3.20 (on Linux) streamlines scrollbars and gutters to the point where there's no longer a need to create a custom plugin to hide space-wasting elements. To hide entire toolbar row, just a click away: Window > Appearance > Hide ToolBar. Bottom status bar? Just define override attribs and import custom css file into target theme a la #import('custom_gtk.css'):
#org-eclipse-ui-trim-status,
#org-eclipse-ui-trim-vertical2,
#org-eclipse-ui-main-toolbar {
visibility: hidden;
}
There is, however, one issue I have been unable to workaround via custom css: in split editor layouts a separate top row appears with min/max buttons. The row serves no purpose since max button is not attached to any editor panel file (i.e. clicking max button does nothing). The end result is 20-30px of wasted vertical space.
Have tried various override incantations using CSS Spy, but none have worked. Would love to find a solution to this problem as out of the box space preserving VIM-like editing is nearly at hand in Neon.
Here's E4 Bugzilla tracker issue (generally not much activity there so trying SO in hopes of finding a solution or possible workarounds).
This is a bit heavy handed but does the trick. In my eclipse plugins/org.eclipse.ui.theme.../css directory I have a custom_gtk.css file with, among other overrides, the following:
CTabFolder {
swt-maximize-visible: false;
swt-minimize-visible: false
}
Hides all min/max elements and the extraenous row in which the elements are defined (if editor tabs exist then the row remains, only min/max buttons are hidden).

How to make bootstraps's "split button" in Qt widgets

This is probably simple, though I can't find the correct CSS trick to handle this one.
I want to have this kind of button-group (separated with lines, containing a context menu ) in Qt. They must have native look and feel (not like below examples) so the only needed change seems to be removing rounded corners of a QPushButton from its right side (for left-most button), left side (for right most button) and both (for buttons in the middle).
Qt does not support this. You can use CSS to style the buttons like in the example, but you can not use natively styled buttons like this.
If you really need this, the only option I see is to write custom controls for this, with customized drawing code for each OS GUI style you want to support.
You could also try to use standard buttons that overlap and use custom code to paint some kind of line over the overlapping region, but I don't think that would be a good solution.

QT how to get rid of spaces between widgets and their parents

I love designing my userinterfaces in qtdesigner because its just so damn simple. However, there is always space in between widgets and their parents which i want to eliminate.
Example of problem
I create a simple dialog and add a webview to it. Then layout horizontally.To make the parent more obvious I modify its css to make its background color green
Voila, I want to get rid of the green sections because in my view they make the program look ugly.
Link to my ui file.
Download ui file from my dropbox
or get it from pastebin
In Qt Designer, select your top level widget (in this case Dialog), then look at the Property Editor on the right-hand sidebar. Scroll all the way down and you'll see a section referring to the layout assigned to that widget. You want to change the layoutLeftMargin, layoutRightMargin, etc. properties.

Qt radio button switch display delay

I'm having a Qt application here where I have a main window with 5 QPushButtons that are aligned vertically.
These buttons work in a radio-group manner.
This means, that they are checkable and auto-exclusive.
Since I need to be able to resize the font size of the button text when the main window resizes, I included my own override of QPushButton and set it as custom widget in designer.
What I don't understand is, that there is a heavy delay when I switch from one button to another via keyboard shortcuts! Same when I click with the mouse.
I would say that this delay is about 0.5 to 1 second.
Have tried it on different machines.
I really need to get rid of this!
Anyone has an idea of what I could do to fix this??
Edit : Just found out that this behavior is the same when I just use normal QPushButtons. It seems that the delay is getting more when the buttons are getting bigger. Any help is strongly appreciated!!!
A shot in the dark: Setting the font might cause another resizeEvent, which in turn causes another one and so on... Try putting the font adjustment code into a method that you explicitly call when you enter/leave full screen mode.

Resources