I have a very simple Plasmoid (it consists of only 1 JS file and 1 main.qml file). I've been browsing the internet for almost an eternity, but I can't figure out, how to set an icon the for the plasmoid to use in the KDE panel.
In 5 minutes I found a tutorial and a quick browse of the sources shows that you should add an "Icon" entry in your plasmoid metadata.desktop file.
See the Calculator applet as a simple example:
https://cgit.kde.org/kdeplasma-addons.git/tree/applets/calculator/package/metadata.desktop#n117
That icon should then translate into those SVG icons (per theme) you have in /usr/share/icons
Related
When I create the "Command link button" (QCommandLinkButton) it has relatively nice green arrow icon.
I would like to see what other nice icons can I choose. When I try to change the icon, [Theme] appears instead of path or some GUI selection dialog:
I also noticed the context menu:
When I click Set icon from theme, again expecting some GUI selection list, I get just a text field:
What I was imagining:
Where's the list of icons from which the green arrow was taken?
QIcon::fromTheme works under specific conditions.
If it can find it in the QIcon::themeSearchPaths() for the QIcon::themeName()
If the desired icon isn't there, Qt Designer won't be able to do any of the from theme, named icons.
But... if you check your target system for the theme search paths and set the theme name, you are more likely to have success.
Example
On linux, I wanted to get a plus and a minus icon.
I found list-add.png and list-remove.png fit the bill.
https://github.com/GNOME/adwaita-icon-theme/tree/master/Adwaita/16x16/actions
http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
I did a locate on my system and found these:
/usr/share/icons/gnome/16x16/actions/list-add.png
...
/usr/share/icons/gnome/32x32/actions/list-add.png
/usr/share/icons/gnome/scalable/actions/list-add.svg
/usr/share/icons/oxygen/16x16/actions/list-add.png
...
Forcing with fallback icon in QIcon::fromTheme
Find the icon on the filesystem:
ui->toolButton->setIcon(QIcon::fromTheme("list-add",
QIcon("/usr/share/icons/gnome/16x16/actions/list-add.png")));
Find the icon in the qt resource system...
Add the icon in a qrc file in your build, then reference it's path.
ui->toolButton->setIcon(QIcon::fromTheme("list-add",
QIcon(":/list-add.png")));
Overriding the current icon theme
qDebug() << "themeSearchPaths:" << QIcon::themeSearchPaths() << QIcon::themeName();
// themeSearchPaths: ("/usr/local/share/icons", "/usr/share/icons", ":/icons") "hicolor"
The default theme for the system, and for the target deployment machine, likely didn't have the icons in it I wanted... but the gnome or oxygen icon desktop theme installed would almost always have it...
QIcon::setThemeName("oxygen");
Note that you won't see the preview in Qt Designer necessarily because it doesn't set the theme until runtime of your code.
The gnome icon library has 1100+ icons in it. Here is one list:
https://gist.github.com/peteristhegreat/c0ca6e1a57e5d4b9cd0bb1d7b3be1d6a
This works as long as you know what themes are available on the target system.
The list from freedesktop.org has 286 icons listed.
Use icons included in Qt
Just like #peppe pointed out, Qt includes 70 standard icons, too.
widget->setIcon(widget->style()->standardIcon(QStyle::SP_BrowserReload));
http://doc.qt.io/qt-5/qstyle.html#StandardPixmap-enum
Conclusion
Using a stock library on your target system is probably the fastest. Using the Qt built-ins is fast to figure out and use, but is fairly limited. Using a resource file is probably the most robust method, and gives unlimited options on what icon to use.
Be sure to pick a standard icon pack, and think about licensing and attributions, and some other things like that.
And there is no shortage of icons available online:
https://www.quora.com/What-is-the-best-icon-library
https://www.google.com/search?q=open+source+icon+library
Hope that helps.
I don't think that's the function you want to use. The "theme" name there corresponds to the QIcon::fromTheme functionality, which uses icons named according to the FDO specification
http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
And they're not really supported on non-FDO platforms (Windows, Mac, ...) unless you deploy your own theme files.
Now some stock icons are shipped with Qt itself; I don't know how to set them from Designer, but from code you can use QStyle::standardIcon:
widget->setIcon(widget->style()->standardIcon(QStyle::SP_BrowserReload));
If the icon you need is not provided by Qt, you'll need to ship it. In that case the Resource System is a convenient way to bundle it alongside your executable.
Last, but not least, from a UX point of view you should consider using QToolButtons unless you're really building a Vista-like wizard.
I'm working on a Qt UI that will run on a touchscreen. At some point it will be useful to select files, in (probably) a QFileDialog.
But little icons on a QFileDialog leads to a terrible touch-user experience, I'd like them to be bigger, so the user doesn't get crazy trying to navigate in the filesystem.
Actually, I'm searching documentation to see if there is a way through css, but haven't seen yet which target/propery to use.
Given the doc of QFileDialog class:
QFileDialog::Detail 0 Displays an icon, a name, and details for each item in the directory.
QFileDialog::List 1 Displays only an icon and a name for each item in the directory.
You can't set icon size this way. I recommend you to set a custom icon provider on the QFileDialog.
OS X 10.7.5, Eclipse 4.3 Kepler build ID 20130919-0819, Java 1.7.0_51
I'm following along the Vogel tutorial, and I have (another) problem. I've added a toolbar as described in the tutorial, but no icons appear on the toolbar. The toolbar itself appears, but it is empty. If I click in the empty space where the icon should be, the handler is called as expected. I can add an icon file to my project, and have my HandledToolItem point to it, and in that case the icon is visible, and operates as expected.
Should I expect default icons to appear automatically? Do I have to import or include standard Eclipse icons somehow? Or do I have to add each icon manually (I rather doubt this is the case.)
Thanks, gary
You can add Icons via the platform-notation, e.g. platform:/plugin/de.myplugin.ui/icons/icon.gif.
Using this way, you can also access eclipse-build-in-icons.
See this blogpost: http://codeandme.blogspot.co.at/2012/07/reusing-platform-images.html for a plugin to browse the available plugins.
I am developing an Adobe Air app. I need to set an icon to the app so it is shown on the task bar. I added the icon tag to the descriptor file but it is not working and I really don't know why, any ideas?
Two things that might be throwing you off:
1) the icons block is commented out by default in the auto-generated descriptor file, and is an easy thing to overlook
2) the icons specified in a descriptor file don't appear in the app unless you build a release build, and install the resulting .air file. A debug build will only show the AIR icon.
At least these are the behaviors I experience in Flash Builder 4.
Adding the icons to your application descriptor should do it.
However, icons come in different sizes.
For example:
<icon>
<image16x16>/icons/app/icon_16.png</image16x16>
<image29x29>/icons/app/icon_29.png</image29x29>
<image32x32>/icons/app/icon_32.png</image32x32>
<image36x36>/icons/app/icon_36.png</image36x36>
<image48x48>/icons/app/icon_48.png</image48x48>
<image57x57>/icons/app/icon_57.png</image57x57>
<image72x72>/icons/app/icon_72.png</image72x72>
<image114x114>/icons/app/icon_114.png</image114x114>
<image128x128>/icons/app/icon_128.png</image128x128>
<image512x512>/icons/app/icon_512.png</image512x512>
</icon>
If I'm not mistaken, the 32x32 icon should be the one that is displayed in the taskbar.
Obviously, make sure that you are referring to the correct path in your descriptor file.
One more thing. I just wasted over an hour on this: For an iOS app, you won't see the icon when you drop the app into iTunes (at least not under Windows), but it will appear on your device!
In my last question (Qt/C++: Icons not showing up when program is run) I asked how to get an icon to show up on a toolbar and was told I needed a Qt Resource, which I added and that fixed my problem, the icon did show up on the toolbar.
Now I'm trying to set the title icon of a window, using the same resource file, and it shows up fine in the Qt preview viewer but blank in the actual program. I am using a MainWindow which has an MDIArea and the children are MainWindows as well; neither the parent MDI nor child MDI windows icons will show properly. On the parent, I see the regular "Windows Application icon" and on the child, the icon is completely blank.
How can I solve this?
You will have to go through a standard resource file for windows. (That is, a .rc)
The process (as described in the documentation) is:
Store the ICO file in your application's source code directory, for
example, with the name myappico.ico. Then, create a text file called,
say, myapp.rc in which you put a single line of text:
IDI_ICON1 ICON DISCARDABLE "myappico.ico"
Finally, assuming you are using qmake to generate your makefiles, add this line to your myapp.pro
file: RC_FILE = myapp.rc
Regenerate your makefile and your application. The .exe file will now be represented with your icon in Explorer.
In the Visual Studio case you're simply able to add a resource to your project.