QIcon not shown on Ubuntu, works on Windows
Hi I have a problem in multiple applications which were all developed on a Windows machine. When I build the same apps on Ubuntu and run them开发者_运维知识库, no icons are shown at the File Menu bar alone . Works perfectly in windows. Any suggestion
LoadAction = new QAction(tr("&Open file"), this);
LoadAction->setIcon(QIcon(Dir +"/images/Load.png"));
LoadAction->setShortcut(QKeySequence::Open);
I doubled checked the path ,everything is fine ...
Set the Qt application object's AA_DontShowIconsInMenus global attribute to be false using
application.setAttribute(Qt::AA_DontShowIconsInMenus, false);
Another option is to enable menu icons for individual QActions using QAction::setIconVisibleInMenu.
split that second line , first create the QIcon,then use bool QIcon::isNull () const -method to check if the Icon is loadede and finally set the icon. If it fails to load from that file, then try creating the path first
QString path=Dir+"/images/Load.png";
and check if that path is correct
Also remember that for some image formats you need the plugins(but png will work without those,just if you use other formats like jpg,svg)
Paths are case sensative on Linux computers. Are you sure you don't have an upper case file extension?
Windows would be more forgiving.
The step after that would be to output the path to the debug window and do a QFile::exists test on it.
精彩评论