Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It seems not work in the menu? #10

Open
yarcowang opened this issue Sep 24, 2015 · 15 comments
Open

It seems not work in the menu? #10

yarcowang opened this issue Sep 24, 2015 · 15 comments
Labels

Comments

@yarcowang
Copy link

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
Copy link
Owner

Did you try this on your action?

action->setIconVisibleInMenu(true);

Qt hide's menu icons by default on OSX

@yarcowang
Copy link
Author

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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Author

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

@gamecreature
Copy link
Owner

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
Copy link
Author

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

@gamecreature
Copy link
Owner

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
Copy link

@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
Copy link
Owner

@SylvainCorlay, Thanks! I would really appreciate that!

@SylvainCorlay
Copy link

The OS X issue we had in the python port is fixed by SylvainCorlay/qtawesome@40a7bcc .

Rather than addApplicationFontFromData, one can directly call addApplicationFont with a filename, and things work.

@gamecreature
Copy link
Owner

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

@gamecreature gamecreature reopened this Sep 26, 2015
@gamecreature
Copy link
Owner

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
Copy link

drydh commented Oct 2, 2016

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

@gamecreature
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants