Something like this:

MainWindow::buildIcon
/**
 * @brief Append a regularly defined set of sized icon images to a QIcon.
 *
 * The following usage example assumes the resources ":myIcons/16x16/exit.png",
 * ":myIcons/24x24/exit.png", and ":myIcons/32x32/exit.png" are available and
 * that we want to bundle them together into exitIcon.
 *
 * \code
 *   QList<int> sizes; sizes << 16 << 24 << 32;
 *   QIcon exitIcon;
 *   buildIcon(&exitIcon, ":myIcons/%size%/exit.png", sizes);
 * \endcode
 *
 * Does NOT check whether the referenced resources actually exist.
 *
 * @param theIcon Pointer to the icon that will be built/appened to.
 * @param iconRscTemplate A tag-based template string for the icon resource.
 *                        Two tags are recognized in iconRscTemplate: \%size\%
 *                        and \%dim\%. When the iconRscTemplate is expanded, the
 *                        tag \%dim\% will be replaced by {iconSize} and
 *                        \%size\% will be replaced by {iconSize}x{iconSize},
 *                        where {iconSize} is a string cast of an element in
 *                        sizeList.
 * @param sizeList A list of single-dimension sizes to be added to the icon.
 *
 * @return void
 */
void MainWindow::buildIcon(QIcon* const theIcon,
                           QString const &iconRscTemplate,
                           QList<int> const &sizeList)
{
    foreach (const int iconSize, sizeList)
    {
        QString theResource = iconRscTemplate;
        QString dim; dim.setNum(iconSize);
        theResource.replace(QString("%dim%"), dim);
        theResource.replace(QString("%size%"), dim +"x"+dim);
 
        theIcon->addFile(theResource, QSize(iconSize, iconSize));
    }
}