Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QAction just shows icon but no text
Qt 6.11 is out! See what's new in the release blog

QAction just shows icon but no text

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GGG03
    wrote on last edited by
    #1
    #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?

    JoeCFDJ JonBJ 2 Replies Last reply
    0
    • G GGG03
      #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?

      JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by
      #2

      @GGG03 Qt5 or Qt6?

      G 1 Reply Last reply
      0
      • JoeCFDJ JoeCFD

        @GGG03 Qt5 or Qt6?

        G Offline
        G Offline
        GGG03
        wrote on last edited by
        #3

        @JoeCFD QT5

        JoeCFDJ 1 Reply Last reply
        0
        • G GGG03
          #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?

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by JonB
          #4

          @GGG03
          Confirm the class of your menuBar, don't make us guess? Might it be a QToolBar?

          G 1 Reply Last reply
          0
          • JonBJ JonB

            @GGG03
            Confirm the class of your menuBar, don't make us guess? Might it be a QToolBar?

            G Offline
            G Offline
            GGG03
            wrote on last edited by
            #5

            @JonB it is a QMenuBar

            SGaistS 1 Reply Last reply
            0
            • G GGG03

              @JonB it is a QMenuBar

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              Which release of Qt 5 ?
              Which OS are you running ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              G 1 Reply Last reply
              0
              • G GGG03

                @JoeCFD QT5

                JoeCFDJ Offline
                JoeCFDJ Offline
                JoeCFD
                wrote on last edited by JoeCFD
                #7

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

                G 1 Reply Last reply
                1
                • SGaistS SGaist

                  Hi,

                  Which release of Qt 5 ?
                  Which OS are you running ?

                  G Offline
                  G Offline
                  GGG03
                  wrote on last edited by
                  #8

                  @SGaist I'm running QT 5.15.11 and Windows 11

                  1 Reply Last reply
                  0
                  • JoeCFDJ JoeCFD

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

                    G Offline
                    G Offline
                    GGG03
                    wrote on last edited by
                    #9

                    @JoeCFD I don't understand why in your machine works

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved