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

  • Home
  • SEARCH
  • 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 580121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:26:21+00:00 2026-05-13T14:26:21+00:00

I just started using QtCreator tonight, and it seems it puts all of the

  • 0

I just started using QtCreator tonight, and it seems it puts all of the interface stuff inside of the ui file. I followed a tutorial to create a resource for my icons, then I added them to a menu bar at the top.

I need to make a connection when one of them is clicked though, and cannot figure out how to make a callback for it.
Am I going to have to completely create them through code or is there some way to add a callback for them (rather than just making them interact with other objects).

  • 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-13T14:26:21+00:00Added an answer on May 13, 2026 at 2:26 pm

    Menu bar items are action objects. To do something when they are clicked, you need to catch the triggered() signal from the action. Read more about signals and slots here.

    To do this, you need to declare a new slot in your MainWindow class. Qt also supports doing this automatically, without the need to connect anything, but I prefer doing it myself. If you’re not interested, just skip this part.

    First, we declare a new slot in your window class:

    private slots:
      void clickMenuButton();
    

    Then, in your constructor, you need to connect the triggered signal to your new slot:

    connect(ui.actionObject, SIGNAL(triggered()), this, SLOT(clickMenuButton()));
    

    The first argument is the object that holds the signal we’ll listen to (your menu button). The second is the name of the signal. The third is the object that holds the receiving slot (in this case, our window). The fourth is the slot.

    And just like that, clickMenuButton() will be called whenever the action is clicked.

    As I said before, Qt can also automatically connect signals to slots. The disadvantage here seems to be that you can’t change the slot’s name, but you don’t need to connect it either.

    Qt Creator supports creation of slots for widgets: in the case of your menu action, you should go to the form designer, and you should see a list of actions in your form (if you don’t, find the Action Editor). Right click the action you want, and push Go to slot…. There, double click triggered().

    Qt Creator will then open the new slot in your code editor, and you can do whatever you want to here!

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

Sidebar

Related Questions

I just started using rapidxml. I 1st create an xml file to read from.
I just started using/learning Python and have some questions. I have a text file
I just started using git with github. I followed their instructions and ran into
Just started using Java (for Android, if that matters) and all I want is
I just started using Fiddler 2 to create request objects for REST,JSON, and SOAP
I just started using Caliburn.Micro and I've noticed in all the examples that the
I just started using Selenium 2 tonight so this will be very basic (I
I just started using resharper and I am trying to learn all the hotkeys
I just started using Coderush and found some stuff that I used to have
I just started using resharper and it barks at this generated assemblyinfo.cs file. Reason/Logic

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.