stefanadelbert
12th May 2011, 03:26
I have a number of different sizes of each icon I use in my app all in one resource file (icons.qrc). Here is an extract from icons.qrc:
<qresource prefix="/Icons/Flags">
<file alias="Australia">Icons/Flags/24x24/Australia.png</file>
<file alias="Australia">Icons/Flags/32x32/Australia.png</file>
<file alias="Australia">Icons/Flags/48x48/Australia.png</file>
<file alias="Australia">Icons/Flags/64x64/Australia.png</file>
<file alias="Australia">Icons/Flags/128x128/Australia.png</file>
<file alias="Australia">Icons/Flags/256x256/Australia.png</file>
<file alias="USA">Icons/Flags/24x24/United-States.png</file>
<file alias="USA">Icons/Flags/32x32/United-States.png</file>
<file alias="USA">Icons/Flags/48x48/United-States.png</file>
<file alias="USA">Icons/Flags/64x64/United-States.png</file>
<file alias="USA">Icons/Flags/128x128/United-States.png</file>
<file alias="USA">Icons/Flags/256x256/United-States.png</file>
</qresource>
I initialise the resource:
Q_INIT_RESOURCE(icons);
And I use the icons in code:
countryButton->setIcon(QIcon(":/Icons/Flags/Australia"));
Everything works fine, except that since upgrading to Qt 4.7.2, I'm getting these Qt warnings at compile time:
1>Rcc'ing icons.qrc...
1>d:\dev\asap\trunk\Epoch\ASAP\Client\Resources\icon s.qrc: Warning: potential duplicate alias detected: 'Australia'
1>d:\dev\asap\trunk\Epoch\ASAP\Client\Resources\icon s.qrc: Warning: potential duplicate alias detected: 'Australia'
1>d:\dev\asap\trunk\Epoch\ASAP\Client\Resources\icon s.qrc: Warning: potential duplicate alias detected: 'Australia'
1>d:\dev\asap\trunk\Epoch\ASAP\Client\Resources\icon s.qrc: Warning: potential duplicate alias detected: 'Australia'
1>d:\dev\asap\trunk\Epoch\ASAP\Client\Resources\icon s.qrc: Warning: potential duplicate alias detected: 'Australia'
1>d:\dev\asap\trunk\Epoch\ASAP\Client\Resources\icon s.qrc: Warning: potential duplicate alias detected: 'USA'
1>d:\dev\asap\trunk\Epoch\ASAP\Client\Resources\icon s.qrc: Warning: potential duplicate alias detected: 'USA'
1>d:\dev\asap\trunk\Epoch\ASAP\Client\Resources\icon s.qrc: Warning: potential duplicate alias detected: 'USA'
1>d:\dev\asap\trunk\Epoch\ASAP\Client\Resources\icon s.qrc: Warning: potential duplicate alias detected: 'USA'
1>d:\dev\asap\trunk\Epoch\ASAP\Client\Resources\icon s.qrc: Warning: potential duplicate alias detected: 'USA'
I understand why I'm getting the warnings, but I would like to know what the convention or best practice is. Ideally I don't want to have to be specific about the resolution of the icon I'm referring to in the code, i.e. I don't want to do this:
smallCountryButton->setIcon(QIcon(":/Icons/Flags/Australia_16"));
bigCountryButton->setIcon(QIcon(":/Icons/Flags/Australia_64"));
Is there something behind the scenes that will decide on the best icon to use if there are duplicate aliases?
<qresource prefix="/Icons/Flags">
<file alias="Australia">Icons/Flags/24x24/Australia.png</file>
<file alias="Australia">Icons/Flags/32x32/Australia.png</file>
<file alias="Australia">Icons/Flags/48x48/Australia.png</file>
<file alias="Australia">Icons/Flags/64x64/Australia.png</file>
<file alias="Australia">Icons/Flags/128x128/Australia.png</file>
<file alias="Australia">Icons/Flags/256x256/Australia.png</file>
<file alias="USA">Icons/Flags/24x24/United-States.png</file>
<file alias="USA">Icons/Flags/32x32/United-States.png</file>
<file alias="USA">Icons/Flags/48x48/United-States.png</file>
<file alias="USA">Icons/Flags/64x64/United-States.png</file>
<file alias="USA">Icons/Flags/128x128/United-States.png</file>
<file alias="USA">Icons/Flags/256x256/United-States.png</file>
</qresource>
I initialise the resource:
Q_INIT_RESOURCE(icons);
And I use the icons in code:
countryButton->setIcon(QIcon(":/Icons/Flags/Australia"));
Everything works fine, except that since upgrading to Qt 4.7.2, I'm getting these Qt warnings at compile time:
1>Rcc'ing icons.qrc...
1>d:\dev\asap\trunk\Epoch\ASAP\Client\Resources\icon s.qrc: Warning: potential duplicate alias detected: 'Australia'
1>d:\dev\asap\trunk\Epoch\ASAP\Client\Resources\icon s.qrc: Warning: potential duplicate alias detected: 'Australia'
1>d:\dev\asap\trunk\Epoch\ASAP\Client\Resources\icon s.qrc: Warning: potential duplicate alias detected: 'Australia'
1>d:\dev\asap\trunk\Epoch\ASAP\Client\Resources\icon s.qrc: Warning: potential duplicate alias detected: 'Australia'
1>d:\dev\asap\trunk\Epoch\ASAP\Client\Resources\icon s.qrc: Warning: potential duplicate alias detected: 'Australia'
1>d:\dev\asap\trunk\Epoch\ASAP\Client\Resources\icon s.qrc: Warning: potential duplicate alias detected: 'USA'
1>d:\dev\asap\trunk\Epoch\ASAP\Client\Resources\icon s.qrc: Warning: potential duplicate alias detected: 'USA'
1>d:\dev\asap\trunk\Epoch\ASAP\Client\Resources\icon s.qrc: Warning: potential duplicate alias detected: 'USA'
1>d:\dev\asap\trunk\Epoch\ASAP\Client\Resources\icon s.qrc: Warning: potential duplicate alias detected: 'USA'
1>d:\dev\asap\trunk\Epoch\ASAP\Client\Resources\icon s.qrc: Warning: potential duplicate alias detected: 'USA'
I understand why I'm getting the warnings, but I would like to know what the convention or best practice is. Ideally I don't want to have to be specific about the resolution of the icon I'm referring to in the code, i.e. I don't want to do this:
smallCountryButton->setIcon(QIcon(":/Icons/Flags/Australia_16"));
bigCountryButton->setIcon(QIcon(":/Icons/Flags/Australia_64"));
Is there something behind the scenes that will decide on the best icon to use if there are duplicate aliases?