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. How do I connect an action responding to a menu bar item?
Forum Update on Monday, May 27th 2025

How do I connect an action responding to a menu bar item?

Scheduled Pinned Locked Moved Solved General and Desktop
widget
3 Posts 2 Posters 346 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.
  • J Offline
    J Offline
    jdent
    wrote on 5 Mar 2024, 12:02 last edited by
    #1

    I am lost here...
    I created a menu in Qt Designer, but how do I implement the connection to the function I want called ??

    Regards,
    Juan Dent

    P 1 Reply Last reply 5 Mar 2024, 12:08
    0
    • J jdent
      5 Mar 2024, 12:02

      I am lost here...
      I created a menu in Qt Designer, but how do I implement the connection to the function I want called ??

      Regards,
      Juan Dent

      P Offline
      P Offline
      Pl45m4
      wrote on 5 Mar 2024, 12:08 last edited by Pl45m4 3 May 2024, 12:15
      #2

      @jdent said in How do I connect an action responding to a menu bar item?:

      I created a menu in Qt Designer, but how do I implement the connection to the function I want called ??

      connect(ui->yourMenuAction, &QAction::triggered, this, &MainWindow::yourFunction);
      

      For the first parameter, use the ui pointer to access objects in your generated form class... then pick the object name of the item you want to use.
      All access to objects created in Designer works like ui->objectname (you find the name in QtDesigner's object inspector list)

      Read more about Signals & Slots here:

      • https://doc.qt.io/qt-6/signalsandslots.html

      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      J 1 Reply Last reply 5 Mar 2024, 15:39
      2
      • P Pl45m4
        5 Mar 2024, 12:08

        @jdent said in How do I connect an action responding to a menu bar item?:

        I created a menu in Qt Designer, but how do I implement the connection to the function I want called ??

        connect(ui->yourMenuAction, &QAction::triggered, this, &MainWindow::yourFunction);
        

        For the first parameter, use the ui pointer to access objects in your generated form class... then pick the object name of the item you want to use.
        All access to objects created in Designer works like ui->objectname (you find the name in QtDesigner's object inspector list)

        Read more about Signals & Slots here:

        • https://doc.qt.io/qt-6/signalsandslots.html
        J Offline
        J Offline
        jdent
        wrote on 5 Mar 2024, 15:39 last edited by
        #3

        @Pl45m4 Thanks!!!!

        1 Reply Last reply
        0
        • J jdent has marked this topic as solved on 5 Mar 2024, 20:38

        1/3

        5 Mar 2024, 12:02

        • Login

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