QAction just shows icon but no text
-
#include "dualscreen.h" #include "ui_dualscreen.h" #include <QWidget> #include <QMenuBar> dualScreen::dualScreen(QWidget *parent) : QWidget(parent), ui(new Ui::dualScreen) { ui->setupUi(this); //zoom->setIconText("AutoZoom"); zoom->setIcon(QIcon(":/models/AutoZoom.png")); zoom->setText("AutoZoom"); menuBar->addAction(zoom); menuBar->setStyleSheet("background-color: rgb(134,199,218); font-family: \"Consolas\"; font-weight: bold"); ui->gridLayout->setMenuBar(menuBar); connect(zoom, SIGNAL(triggered()), this, SLOT(zoomChecked())); }
I don't understand why it just shows the icon. Can anyone help me?
-
#include "dualscreen.h" #include "ui_dualscreen.h" #include <QWidget> #include <QMenuBar> dualScreen::dualScreen(QWidget *parent) : QWidget(parent), ui(new Ui::dualScreen) { ui->setupUi(this); //zoom->setIconText("AutoZoom"); zoom->setIcon(QIcon(":/models/AutoZoom.png")); zoom->setText("AutoZoom"); menuBar->addAction(zoom); menuBar->setStyleSheet("background-color: rgb(134,199,218); font-family: \"Consolas\"; font-weight: bold"); ui->gridLayout->setMenuBar(menuBar); connect(zoom, SIGNAL(triggered()), this, SLOT(zoomChecked())); }
I don't understand why it just shows the icon. Can anyone help me?
-
#include "dualscreen.h" #include "ui_dualscreen.h" #include <QWidget> #include <QMenuBar> dualScreen::dualScreen(QWidget *parent) : QWidget(parent), ui(new Ui::dualScreen) { ui->setupUi(this); //zoom->setIconText("AutoZoom"); zoom->setIcon(QIcon(":/models/AutoZoom.png")); zoom->setText("AutoZoom"); menuBar->addAction(zoom); menuBar->setStyleSheet("background-color: rgb(134,199,218); font-family: \"Consolas\"; font-weight: bold"); ui->gridLayout->setMenuBar(menuBar); connect(zoom, SIGNAL(triggered()), this, SLOT(zoomChecked())); }
I don't understand why it just shows the icon. Can anyone help me?
-
Hi,
Which release of Qt 5 ?
Which OS are you running ? -
@GGG03 I tested open action in /widgets/mainwindows/application in Qt Examples on Ubuntu 22.04 and Qt 5.15.3.
Your code works fine. Both text and icon of open action show up.