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. Show Icon and Text for QToolButton with defaultAction
Forum Updated to NodeBB v4.3 + New Features

Show Icon and Text for QToolButton with defaultAction

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 8.6k Views 2 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.
  • S Offline
    S Offline
    sarlaa
    wrote on last edited by
    #1

    I have QToolButton with ToolButtonStyle ToolButtontTextBesideIcon, that has a default action with setDefaultAction(). My QAction has icon (using setIcon()) and text using (setText()), but It show's ony the icon. So how can I show both icon and text ?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      What version of Qt are out using ?
      On what platform ?
      With which compiler ?
      Can you provide a minimal sample example so that other people can test it ?

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

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ambershark
        wrote on last edited by
        #3

        Works fine for me.... Example code below:

            auto toolButton = new QToolButton(toolBar);
            toolButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
            auto act = new QAction();
            act->setIcon(QIcon(":/icon.png"));
            act->setText("some text");
            toolButton->setDefaultAction(act);
        

        My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

        1 Reply Last reply
        1

        • Login

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