Verve Innovation
Verve Innovation

Reputation: 2096

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 ...

Upvotes: 1

Views: 932

Answers (3)

Phil Hannent
Phil Hannent

Reputation: 12317

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.

Upvotes: 0

Mukul M.
Mukul M.

Reputation: 541

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.

Upvotes: 1

simion314
simion314

Reputation: 1394

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)

Upvotes: 0

Related Questions