How to set icon for QtSystemTrayIcon? - qt

I am having a situation using QSystemTrayIcon to set an icon into it. I have a 16x16 icon in png format. With the following code:
m_pTray->setIcon(QIcon (":/res/systemtray.png"));
The icon still not showing up. May I know is it something to do with the path? I have set the full path but still not working.
I am doing it in VS2005. May I know is there a workaround for this?
THanks!

Related

qt qtoolbutton icon blurry

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

Vertically center text near an image in a QLabel

I am attempting to get a QLabel display an image and some text centered vertically with that image.
I can't figure out how to do this.
Most sources I've found on the internet suggest using the following code:
ui->label->setText("<img src='c:/images.jpg' style='vertical-align:middle;'> Hello");
However what I get is this.
The bottom line of the text is centered near the image, but what I like to have is the middle line of the text to be centered (like so: made in ms paint). Sounds like a pretty common task yet I wasn't able to find any answer.
How can I achieve this?
I tried to run it in my QtCreator and it work fine. So, for start, you can try the following:
Check the picture size. Open it in paint.net or something like that. Perhaps the top image is an empty area of ​​the invisible. Those, the actual size of the image looks like an elongated rectangle, in which the visible part is on the bottom. Try other image.
Try to change the format jpg to png. I had problems with displaying images in jpg format, so I always try to use the png.
Problems with styles. Qt may work incorrect with css style, because it not part of the Qt. I tested in version Qt 5.4.0. If you have an older, may be its time to update it.

Set console font size example

I want to change console font size on windows. I figured out it should be done with SetCurrentConsoleFontEx but i don't know how.
would appreciate if you provide an example.
Thanks.
Its pretty simple...Start cmd, right click on title, go to properties, than go to fonts and than you will see this:
Screenshot
And than change font size value and thats that :)
On windows 7
CMD window->Right Click CMD icon (upper left corner)->Properties->Font

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.

Easy way to build a webfont based off of .png files

Designer at our company has provided me an icon set as a series of .png files (1x and 2x per icon) that I'd really like to switch over to be a webfont instead.
Is there a best practice for doing this sort of thing?
If your png's are of good quality you can open them in Adobe Illustrator.
Click on an image. On the top bar, a button 'Image Trace' ('Bildnachzeichner' in german) appears. Click on small arrow next to 'Image Trace' box for drop down menu.
Select ‘High Fidelity Photo’ to begin image trace, if the result doesn't fit try other options from the drowndown menu.
Next you will see an 'Expand'-Button at the top ('Umwandeln' in german).
Click it. Vercotr paths and fills are created.
You can adjust them if you need and save it to a svg file.
Then import to icomoon.io ...
I've used icomoon.io in the past. I think with only .png files though you can only make an image sprite. You'll need the files in .svg format to make an icon font.
DON'T DO IT.
Use a sprite sheet instead.

Resources