qt:icons
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
qt:icons [2011/05/12 09:23] – [System theme using QIcon::fromTheme()] mithat | qt:icons [2011/05/13 11:19] – mithat | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Icons and Actions ====== | ====== Icons and Actions ====== | ||
- | This report discusses different ways of binding icons to actions in Qt desktop applications and provides motivation for exploring | + | This report discusses different ways of binding icons to actions in Qt desktop applications and provides motivation for developing |
In Qt, there are (at least) five different approaches to binding icons((http:// | In Qt, there are (at least) five different approaches to binding icons((http:// | ||
Line 7: | Line 7: | ||
===== Using Qt Resources in Qt Designer ===== | ===== Using Qt Resources in Qt Designer ===== | ||
- | The path-of-least-resistance for binding icons to actions when developing Qt applications with Qt Designer((Throughout, | + | The path-of-least-resistance for binding icons to actions when developing Qt applications with Qt Designer((Throughout, |
- | While this approach has the above stated benefits, it's not optimal for a couple reasons. First, it lacks the ability to specify multiple icon sizes. In a typical application, | + | While this approach has the above stated benefits, it's not optimal for a couple reasons. First, it lacks the ability to specify multiple icon sizes. In a typical application, |
- | Developers using this approach typically provide an icon in a resource that is as large as the application is likely to require, and then let Qt resize it as needed. Thus, for example, you might bind a 48x48 icon to an action and let Qt shrink it to 24x24 for the toolbar and 16x16 for the menu item. While this works, the shrunk icons often appear fuzzy or otherwise suboptimal((As near as I can tell, it's not possible to specify multi-sized icons in Qt Designer. You can supply Windows-style multi-size '' | + | Developers using this approach typically provide an icon in a resource that is as large as the application is likely to require, and then let Qt resize it as needed. Thus, for example, you might bind a 48x48 icon to an action and let Qt shrink it to 24x24 for the toolbar and 16x16 for the menu item. While this works, the shrunk icons often appear fuzzy and/or otherwise suboptimal((As near as I can tell, it's not possible to specify multi-sized icons in Qt Designer. You can supply Windows-style multi-size '' |
FIXME (an image here would help a lot) | FIXME (an image here would help a lot) | ||
Line 72: | Line 72: | ||
": | ": | ||
documentOpenIcon.addFile( | documentOpenIcon.addFile( | ||
- | ": | + | ": |
ui-> | ui-> | ||
Line 81: | Line 81: | ||
": | ": | ||
saveAsIcon.addFile( | saveAsIcon.addFile( | ||
- | ": | + | ": |
ui-> | ui-> | ||
Line 90: | Line 90: | ||
": | ": | ||
exitIcon.addFile( | exitIcon.addFile( | ||
- | ": | + | ": |
ui-> | ui-> | ||
Line 96: | Line 96: | ||
}</ | }</ | ||
- | If you have more than a handful of such icons, you will probably want to write a helper function | + | If you have more than a handful of such icons, you will probably want to write a [[MainWindow-buildIcon|support method]] |
==== Pros ==== | ==== Pros ==== |
qt/icons.txt · Last modified: 2011/05/13 17:01 by mithat