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:31] – [Using Qt Resources in Qt Designer] mithat | qt:icons [2011/05/13 16:52] – [QStyle's standardIcon() function] 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, | ||
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 ==== | ||
Line 109: | Line 109: | ||
===== QStyle' | ===== QStyle' | ||
- | An alternative to using icon resources is provided by the '' | + | An alternative to using icon resources is provided by the '' |
- | The enumerated icons should be available on all platforms, so testing for their existence isn't required. | + | The main issue with using '' |
Implementation requires only a bit of straight-forward hand-coding. | Implementation requires only a bit of straight-forward hand-coding. | ||
Line 142: | Line 142: | ||
On X11 systems, Qt lets you access all the icons that are part of the system icon theme using the static function '' | On X11 systems, Qt lets you access all the icons that are part of the system icon theme using the static function '' | ||
- | As was the case with QStyle' | + | As was the case with QStyle' |
==== Code implementation ==== | ==== Code implementation ==== | ||
Line 199: | Line 199: | ||
==== Caveat ==== | ==== Caveat ==== | ||
- | QIcon' | + | QIcon' |
<code cpp-qt> | <code cpp-qt> | ||
QString iconTheme = My:: | QString iconTheme = My:: | ||
QIcon:: | QIcon:: | ||
+ | Until such '' | ||
===== Custom theme using QIcon:: | ===== Custom theme using QIcon:: | ||
Line 272: | Line 273: | ||
Note that in the set of icons I drew from, there were no 48x48 icons. To maintain best compatibility with Windows OSes, you ideally should include 48x48 icons as well((See http:// | Note that in the set of icons I drew from, there were no 48x48 icons. To maintain best compatibility with Windows OSes, you ideally should include 48x48 icons as well((See http:// | ||
- | The pros and cons associated with this approach are essentially identical to [[# | + | The pros and cons associated with this approach are essentially identical to [[# |
==== Code implementation ==== | ==== Code implementation ==== |
qt/icons.txt · Last modified: 2011/05/13 17:01 by mithat