gamecreature / QtAwesome

QtAwesome - Font Awesome for Qt Applications
Other
773 stars 147 forks source link

It seems not work in the menu? #10

Open yarcowang opened 8 years ago

yarcowang commented 8 years ago

I set it in the QAction,

  ui->actionNew_From_Clipboard->setIcon(awesome->icon(fa::beer));

And it appears in toolbar, but in menu item, it just leave empty.

Mac OSX 10.10.2 / Qt 5.3.1

gamecreature commented 8 years ago

Did you try this on your action?

action->setIconVisibleInMenu(true);

Qt hide's menu icons by default on OSX

yarcowang commented 8 years ago

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?

gamecreature commented 8 years ago

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);
gamecreature commented 8 years ago

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

yarcowang commented 8 years ago

Yes, it works! So you mean Only Mac OSX has such problem?

gamecreature commented 8 years ago

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

yarcowang commented 8 years ago

:) Seems we are all using mac, nobody use windows.

gamecreature commented 8 years ago

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.

SylvainCorlay commented 8 years ago

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

gamecreature commented 8 years ago

@SylvainCorlay, Thanks! I would really appreciate that!

SylvainCorlay commented 8 years ago

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.

gamecreature commented 8 years ago

Thanks for this info!! I will check it out later today!

gamecreature commented 8 years ago

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)

drydh commented 7 years ago

I would guess that this bug (icon not shown in menu item) is related to QTBUG 55932.

gamecreature commented 7 years ago

@drydh Yep it sure looks like it's related. Thanks for your comment!