Originally Posted by
wysota
It should take a const char * or QString and return something which is acceptable by QIcon constructor.
Wherever you want.
I can't get it to work. I created the following function:
result.
addFile(QString("images/%1_16x16.png").
arg(iconName.
toLower().
replace(' ',
'_')),
QSize(16,
16));
result.
addFile(QString("images/%1_22x22.png").
arg(iconName.
toLower().
replace(' ',
'_')),
QSize(22,
22));
result.
addFile(QString("images/%1_32x32.png").
arg(iconName.
toLower().
replace(' ',
'_')),
QSize(32,
32));
return result;
}
QIcon createIcon(QString iconName) {
QIcon result;
result.addFile(QString("images/%1_16x16.png").arg(iconName.toLower().replace(' ', '_')), QSize(16, 16));
result.addFile(QString("images/%1_22x22.png").arg(iconName.toLower().replace(' ', '_')), QSize(22, 22));
result.addFile(QString("images/%1_32x32.png").arg(iconName.toLower().replace(' ', '_')), QSize(32, 32));
return result;
}
To copy to clipboard, switch view to plain text mode
I put it in my mainwindow.h, where the subclass of my main window sits.
And I put the word 'createIcon' inside the little textbox. And put mainwindow.h in the include hints.
But the function is never even called. I tried with some debug output.
Obviously I'm still missing something. Could you help me out?
Oh, and what's the string parameter supposed to represent anyway? I'm assuming here that it's the iconText property of the QAction.
I'm sure this could be a useful feature, but they should document it better. How could a person guess all this?
Bookmarks