我在 Qt4 中有一个工作程序。将其移植到 Qt5 后,QActions 的图标不再显示在 QMenu 中;只有文字显示。图标在工具栏中显示正常,但不在菜单中。我已经将应用程序设置为禁用“AA_DontShowIconsInMenus”无济于事。以下是部分代码:
pMenuBar = new QMenuBar(this);
pMenuBar->setObjectName(QString::fromUtf8("Menu Bar"));
pMenuBar->setGeometry(QRect(0, 0, 800, 27));
MyIcon.addFile(":/images/filenew.ico", QSize(), QIcon::Normal, QIcon::On);
pAction = new QAction(tr("&New"), this);
pAction->setIcon(MyIcon);
pAction->setIconVisibleInMenu(true);
pAction->setShortcuts(QKeySequence::New);
pAction->setStatusTip(tr("New"));
pMenuFile = new QMenu(pMenuBar);
pMenuFile->setObjectName(QString::fromUtf8("File Menu"));
// pMenuFile->menuAction()->setIconVisibleInMenu(true);
pMenuFile->addAction(pAction);
pMenuBar->addAction(pMenuFile->menuAction());
setMenuBar(pMenuBar);