qt qtoolbutton icon blurry - qt

I have a problem where the icons used on QToolButtons on the QMenu attached to the QToolButton appear blurry. I have tried different sizes 24x24, 32x32, 64x64, different formats like png and svg but it always looks strange.
On the image you can see the selected action and the top action on the menu have the same icon but the one in the menu is blurry. Even the one selected is not really sharp.
Is there some specific guideline for those icons or what am I doing wrong? The second and third icon is a build in icon which is I believe 24x24 svg but I was not able to reproduce.

Yes, you need to set different sizes of icons if you want them to look good under the QToolButon and in the QMenu, QT will pick up the size that fits best. One possible solution if you are using resource files could be like this:
QIcon *myQIcon = new QIcon;
myQIcon->addFile(":icon24.svg", QSize(24,24));
myQIcon->addFile(":icon16.svg", QSize(16,16));
mMyQAction->setIcon( *myQIcon );
Detailed explanation can be found here: http://mithatkonar.com/wiki/doku.php/qt/icons

Related

Different sizes for application logo - JavaFX

I would like my JavaFX application to use different icons in Windows for the taskbar and the title bar of the window. The first one should be 32x32, while the other one 16x16.
I tried to set multiple icons to the Stage like this:
stage.getIcons().addAll(logo32, logo16);
...but it uses the image logo32 both in the taskbar and the title bar.
This seems something that should be very simple and very common also, so I am wondering if I am doing something wrong. I am using JavaFX 13.
The icon pointed at in this screenshot should not be the same as the one in the taskbar:

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!

Icon overlays are showing blurry on "Large Icons"

We use Icon Overlays to show a state to the users. All but one of our icons are shown sharp.
This unsharpness only happens when we set the explorer to the large icon view.
We can't figure out why this happens.
We tried different tools to create th icon file.
This is the result :
And we started from this image:
You can find the source files (png's) and the ico file here
Does anyone knows how to fix this or what is causing this?
It looks like a specific of Windows resize engine.
In large icons mode shell uses 48x48x32 icon. I created icon with grid:
And shell draws this icon without any interpolation:
And it looks like there is no solution of your problem.

How to change QIcon color?

I am working on a custom control box (that min,max/restore/close button in the top right of your Windows titlebar) for my new application. I use closeIcon = style.standardIcon(QStyle.SP_TitleBarCloseButton) to get the correct icon for them. See the full code here in my other SO question. What I got is a black icon. In which I need the white version when it's in hover state.
Can we .. I don't know, inverse it? Or should I get another icon from QStyle?
This question (and several others) are from the intention of creating a chrome like tab in PyQt application, by hiding the titlebar and reimplementing control box. But it didn't gives the best result. Right now this is my solution to create a chrome like tab in PyQt application. Therefore, I close this question.

QToolBar: styling 'show more' button

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

Resources