QtAwesome icon indicating copy to clipboard operation
QtAwesome copied to clipboard

It seems not work in the menu?

Open yarcowang opened this issue 10 years ago • 15 comments

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

yarcowang avatar Sep 24 '15 01:09 yarcowang

Did you try this on your action?

action->setIconVisibleInMenu(true);

Qt hide's menu icons by default on OSX

gamecreature avatar Sep 24 '15 05:09 gamecreature

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?

yarcowang avatar Sep 24 '15 07:09 yarcowang

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 avatar Sep 24 '15 07:09 gamecreature

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

gamecreature avatar Sep 24 '15 11:09 gamecreature

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

yarcowang avatar Sep 24 '15 11:09 yarcowang

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

gamecreature avatar Sep 24 '15 11:09 gamecreature

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

yarcowang avatar Sep 24 '15 12:09 yarcowang

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 avatar Sep 24 '15 18:09 gamecreature

@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 avatar Sep 24 '15 18:09 SylvainCorlay

@SylvainCorlay, Thanks! I would really appreciate that!

gamecreature avatar Sep 24 '15 19:09 gamecreature

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.

SylvainCorlay avatar Sep 26 '15 03:09 SylvainCorlay

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

gamecreature avatar Sep 26 '15 06:09 gamecreature

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)

gamecreature avatar Sep 27 '15 16:09 gamecreature

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

drydh avatar Oct 02 '16 15:10 drydh

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

gamecreature avatar Oct 03 '16 12:10 gamecreature