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. Is it possible to use the same QAction in different contexts and show its title in only one?
Forum Update on Monday, May 27th 2025

Is it possible to use the same QAction in different contexts and show its title in only one?

Scheduled Pinned Locked Moved Solved General and Desktop
qactionqmenutitle
3 Posts 3 Posters 363 Views
  • 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.
  • L Offline
    L Offline
    leonardo M B
    wrote on last edited by
    #1

    I'm adding the same QAction, already connected to actions, to a QToolBar and to a QMenu. This QAction have a title and an Icon. The problem is that I need the QAction that appears in the QToolbar to show only the icon and not the title, while the QAction that appears in the QMenu show the title and the icon. Is there a way?

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

      Hi,

      You can use the QToolBar::toolButtonStyle property and set it to Qt::ToolButtonIconOnly.

      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
      2
      • L leonardo M B

        I'm adding the same QAction, already connected to actions, to a QToolBar and to a QMenu. This QAction have a title and an Icon. The problem is that I need the QAction that appears in the QToolbar to show only the icon and not the title, while the QAction that appears in the QMenu show the title and the icon. Is there a way?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #2

        @leonardo-M-B
        I would guess not, else there would be an interface to that. Isn't it simpler just to have two QActions which do the same code rather than trying to find a way to do it with one?
        UPDATE Apologies in light of @SGaist's answer.

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

          Hi,

          You can use the QToolBar::toolButtonStyle property and set it to Qt::ToolButtonIconOnly.

          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
          2

          • Login

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