qt:mainwindow-buildicon
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
qt:mainwindow-buildicon [2011/05/12 16:00] – mithat | qt:mainwindow-buildicon [2011/05/13 12:32] (current) – mithat | ||
---|---|---|---|
Line 2: | Line 2: | ||
<code cpp-qt MainWindow:: | <code cpp-qt MainWindow:: | ||
- | #include " | ||
- | #include " | ||
- | |||
- | #include < | ||
- | #include < | ||
- | |||
- | MainWindow:: | ||
- | QMainWindow(parent), | ||
- | ui(new Ui:: | ||
- | { | ||
- | ui-> | ||
- | |||
- | // QIcon:: | ||
- | // ui-> | ||
- | // ui-> | ||
- | // ui-> | ||
- | |||
- | // we need a function that takes QIcon ands the sub-icons automatically: | ||
- | // theQIcon, formatString (with placeholder for size, int array of sizes) | ||
- | |||
- | QIcon documentOpenIcon; | ||
- | documentOpenIcon.addFile( | ||
- | ": | ||
- | documentOpenIcon.addFile( | ||
- | ": | ||
- | documentOpenIcon.addFile( | ||
- | ": | ||
- | ui-> | ||
- | |||
- | QIcon saveAsIcon; | ||
- | saveAsIcon.addFile( | ||
- | ": | ||
- | saveAsIcon.addFile( | ||
- | ": | ||
- | saveAsIcon.addFile( | ||
- | ": | ||
- | ui-> | ||
- | |||
- | QIcon exitIcon; | ||
- | exitIcon.addFile( | ||
- | ": | ||
- | exitIcon.addFile( | ||
- | ": | ||
- | exitIcon.addFile( | ||
- | ": | ||
- | ui-> | ||
- | |||
- | // This mess doesn' | ||
- | // setActionIcon(ui-> | ||
- | // setActionIcon(ui-> | ||
- | // setActionIcon(ui-> | ||
- | |||
- | } | ||
- | |||
- | MainWindow:: | ||
- | { | ||
- | delete ui; | ||
- | } | ||
- | |||
- | bool MainWindow:: | ||
- | | ||
- | | ||
- | // Try to set theAction' | ||
- | // If the iconName isn't found in the system theme, try the backupTheme. | ||
- | // Return true iff the icon was set. | ||
- | // Ha! This doesn' | ||
- | // trying to see what happens when we make a local QIcon to store the icon ... | ||
- | // that doesn' | ||
- | { | ||
- | QString systemTheme = QIcon:: | ||
- | qDebug() << " | ||
- | " | ||
- | " | ||
- | |||
- | if ( !systemTheme.isEmpty() && QIcon:: | ||
- | { | ||
- | QIcon theIcon = QIcon:: | ||
- | theAction-> | ||
- | qDebug() << "set system theme icon for " << iconName; | ||
- | return true; | ||
- | } | ||
- | |||
- | if (!backupTheme.isEmpty()) | ||
- | { | ||
- | QIcon:: | ||
- | if (QIcon:: | ||
- | { | ||
- | QIcon theIcon = QIcon:: | ||
- | theAction-> | ||
- | qDebug() << "Haz backup icon"; | ||
- | } | ||
- | QIcon:: | ||
- | |||
- | qDebug() << "set backup theme icon for " << iconName; | ||
- | return true; | ||
- | } | ||
- | qDebug() << "did not set icon for " << iconName; | ||
- | return false; | ||
- | } | ||
- | |||
- | void MainWindow:: | ||
- | { | ||
- | this-> | ||
- | } | ||
- | |||
/** | /** | ||
- | * Append a regularly defined set of different | + | |
* | * | ||
* The following usage example assumes the resources ": | * The following usage example assumes the resources ": | ||
* ": | * ": | ||
* that we want to bundle them together into exitIcon. | * that we want to bundle them together into exitIcon. | ||
- | | + | * |
* \code | * \code | ||
| | ||
Line 119: | Line 14: | ||
| | ||
* \endcode | * \endcode | ||
- | | + | * |
* Does NOT check whether the referenced resources actually exist. | * Does NOT check whether the referenced resources actually exist. | ||
+ | * | ||
+ | * @param theIcon Pointer to the icon that will be built/ | ||
+ | * @param iconRscTemplate A tag-based template string for the icon resource. | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | * @param sizeList A list of single-dimension sizes to be added to the icon. | ||
* | * | ||
* @return void | * @return void | ||
*/ | */ | ||
- | void MainWindow:: | + | void MainWindow:: |
- | | + | |
- | QList const & | + | QList< |
- | | + | |
{ | { | ||
- | foreach (const int iconSize | + | foreach (const int iconSize, sizeList) |
{ | { | ||
QString theResource = iconRscTemplate; | QString theResource = iconRscTemplate; | ||
- | theResource.replace(QString(" | + | |
- | theResource.replace(QString(" | + | |
+ | theResource.replace(QString(" | ||
- | theIcon-> | + | theIcon-> |
} | } | ||
}</ | }</ |
qt/mainwindow-buildicon.1305216039.txt.gz · Last modified: 2011/05/12 16:00 by mithat