Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6570209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:43:39+00:00 2026-05-25T14:43:39+00:00

I want to show text for the tool button icons using setToolButtonStyle(Qt::ToolButtonTextUnderIcon); I can

  • 0

I want to show text for the tool button icons using setToolButtonStyle(Qt::ToolButtonTextUnderIcon);

I can see the text for actions directly added to Toolbar (Close & Save), but not for an action(Load) that is added to a QMenu in a Toolbutton. I have added this action in Qmenu to work it as a toggle with other actions(recent files).

I tried to set the text for the Toolbutton too using setText() and setWindowIconText(), but it doesn’t work. This is how it looks right now.

Text under icon not working

Below is the code snippet for the same.

actionLoad = new QAction(QIcon(QString("%1/cn_open.png").arg(imageDir)),tr("Load"), this);
actionLoad->setShortcut(tr("Ctrl+L"));
actionLoad->setStatusTip(tr("Load the model"));
connect(actionLoad, SIGNAL(triggered()), this, SLOT(loadModelDlg()));

actionClose = new QAction(QIcon(QString("%1/cn_close.png").arg(imageDir)),tr("Close"), this);
actionClose->setShortcut(tr("Ctrl+X"));
actionClose->setStatusTip(tr("Close the Model"));
connect(actionClose, SIGNAL(triggered()), this, SLOT(closeModel()));

actionSave = new QAction(QIcon(QString("%1/cn_save.png").arg(imageDir)),tr("Save"), this);
actionSave->setShortcut(tr("Ctrl+S"));
actionSave->setStatusTip(tr("Save the Model"));
connect(actionSave, SIGNAL(triggered()), this, SLOT(saveModel()));

m_FileToolBar = addToolBar(tr("File"));
// Show text under the icon in toolbar
m_FileToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);

// Add a menu for recent file items
m_FileMenu     = new QMenu();
m_FileMenu->addAction(actionLoad); // Add load button as the first item
for (int i = 0; i < MaxRecentFiles; ++i)
  m_FileMenu->addAction(recentFileActions[i]);
updateRecentFileActions();

// Create a tool button. Load button and recent files will be added as a drop down menu
m_FileToolButton = new QToolButton();
m_FileToolButton->setText(tr("Load")); // Not working
m_FileToolButton->setWindowIconText(tr("Load")); // Not working
m_FileToolButton->setMenu(m_FileMenu);
m_FileToolButton->setDefaultAction(actionLoad); 

// This creates a dropdown arrow to click.
m_FileToolButton->setPopupMode(QToolButton::MenuButtonPopup); 

m_FileToolBar->addWidget(m_FileToolButton);

// These actions show text under the icon
m_FileToolBar->addAction(actionClose); 
m_FileToolBar->addAction(actionSave);

Any help to resolve this is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:43:39+00:00Added an answer on May 25, 2026 at 2:43 pm

    Why don’t you try something like that:

        QToolBar bar;
        QToolButton button;
    
        button.setPopupMode(QToolButton::MenuButtonPopup);
        button.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    
        QAction loadAction(QIcon(":/img/openfile"),"Load",&button);
        button.addAction(&loadAction);
        button.setDefaultAction(&loadAction);
    
        QAction loadAction2("Load 2",&button);
        button.addAction(&loadAction2);
    
        bar.addWidget(&button);
        bar.show();
    

    I didn’t use a QMenu as you can see above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Delphi, and I want to show custom text in the buttons
I'm using jquery validate to validate my forms. I want to show a text
i want to show text using quartz 2d. Text will be drawing randomly on
How can I show something on screen wihtout using forms? Actually, I want to
I want to show rich text in dropdown control, for which I am using
I do want to show just text inside an INPUT. So, How can I
I just want to show text please wait while app is searching for satellite
if i want to have some text show up in a calligraphy font, how
There is some html text stored in the Database which I want to show
I want to show a chromeless modal window with a close button in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.