Open yarcowang opened 8 years ago
Did you try this on your action?
action->setIconVisibleInMenu(true);
Qt hide's menu icons by default on OSX
That is strange... Default value of iconVisibleInMenu in Qt Designer for the action is already turned on.
awesome = new QtAwesome(this);
awesome->initFontAwesome();
awesome->setDefaultOption("scale-factor", 0.8);
ui->actionNew_From_Clipboard->setIcon(awesome->icon(fa::clipboard));
ui->actionNew_From_Clipboard->setIconVisibleInMenu(true);
ui->actionNew_From_File->setIcon(awesome->icon(fa::file));
ui->actionNew_From_File->setIconVisibleInMenu(true);
ui->actionNew_From_Url->setIcon(awesome->icon(fa::link));
ui->actionNew_From_Url->setIconVisibleInMenu(true);
After i add this, the icon still can not be seem...anything i missed?
Very strange. The good new is the same thing happens over here! I don't have an explanation for it right now. When I use a standard icon it is shown, when I use a QtAwesome Icon it isn't ?!?
QAction* action = new QAction("Test",&w);
// action->setIcon(awesome->icon(fa::beer)); // < this icon doesn't show up
action->setIcon( QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning) ); // < this one does
action->setIconVisibleInMenu(true);
I've found a workaround for this issue: Using pixmap seems to fix it ?!?
action->setIcon(awesome->icon(fa::beer).pixmap(32,32));
(QPixmap is implicitly converted to QIcon)
It looks like the QMenu of Mac OS X doesn't support QIconEngine based icons. But it does support QPixmap based icons... I don't know exactly why...
Yes, it works! So you mean Only Mac OSX has such problem?
I don't know if it's Mac OS X Related. It's an assumption of me... (because I think the Mac OS X menu is not rendered by Qt but by the OS itself) I don't have a windows environment in the neighborhood to test it right now.. But I will check it out later...
:) Seems we are all using mac, nobody use windows.
I've just checked the situation on Windows 10. There it simply works. It is a Mac OS X related, issue. I just added the workaround to the README file.
@gamecreature , some users have experienced issues on Mac in pyqtawesome as well. I will let you know if we come up with a nice solution.
@SylvainCorlay, Thanks! I would really appreciate that!
The OS X issue we had in the python port is fixed by https://github.com/SylvainCorlay/qtawesome/commit/40a7bcc4bc1197c8430bbc87b99749ac819fd043 .
Rather than addApplicationFontFromData
, one can directly call addApplicationFont
with a filename, and things work.
Thanks for this info!! I will check it out later today!
Tried the addApplicationFont, but got no results with the MainMenu... Tried placing the Font Loading before the window creation. Same result.
So no solution yet... (except for adding the .pixmap( .. ) method for creating a pixmap QIcon)
I would guess that this bug (icon not shown in menu item) is related to QTBUG 55932.
@drydh Yep it sure looks like it's related. Thanks for your comment!
I set it in the QAction,
And it appears in toolbar, but in menu item, it just leave empty.
Mac OSX 10.10.2 / Qt 5.3.1