QIcon name() is empty, can we set it on creation?
-
Good day QT'ers, been looking for a way to grab a QIcon name but it's always returning as "".
QIcon pushON; pushOn.addFile(":/img/on.png"); qDebug.log << pushOn.name() <-- returns as ""
Is this a bug in QIcon? Can we set the name when creating the icon?
Thanks and much appreciated.
-
@Calicoder said in QIcon name() is empty, can we set it on creation?:
Is this a bug in QIcon?
No, please read the docs:
Returns the name used to create the icon, if available.
Depending on the way the icon was created, it may have an associated name. This is the case for icons created with fromTheme() or icons using a QIconEngine which supports the QIconEngine::IconNameHook. -
@Christian-Ehrlicher So I should create the icons with a theme for the name() to work?
-
Since QIcon::fromTheme() needs a icon name, QIcon::name() will return it.
-
@Christian-Ehrlicher Perfect, thanks so much