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?

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 359 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 15 Dec 2022, 14:39 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?

    J 1 Reply Last reply 15 Dec 2022, 14:42
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 15 Dec 2022, 19:23 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
        15 Dec 2022, 14:39

        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?

        J Offline
        J Offline
        JonB
        wrote on 15 Dec 2022, 14:42 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
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 15 Dec 2022, 19:23 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

          2/3

          15 Dec 2022, 14:42

          • Login

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