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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:42:15+00:00 2026-06-03T12:42:15+00:00

My problem is that when I click on an item in a QMenuBar, the

  • 0

My problem is that when I click on an item in a QMenuBar, the corresponding slot gets called twice. I’m using Qt 4.8.1. I’m not using Qt Designer nor the “auto-connection” feature. Here is my code snippet :

#include <iostream>
#include <QWidget>
#include <QMenuBar>

class MyWidget : public QWidget
{
        Q_OBJECT
        public:
                MyWidget(QWidget *parent = 0) : QWidget(parent)
                {
                        QMenuBar *menu = new QMenuBar(this);
                        menu->addAction("Click here");
                        menu->addAction("Or here");
                        connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(handleAction(QAction*)));
                }

        public slots:
                void handleAction(QAction *action)
                {
                        std::cout << "Triggered" << std::endl;
                }

};

And the main function :

#include "main.h"
#include <QApplication>

int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    MyWidget w;
    w.show();

    return app.exec();
}

If you compile this (with the MOC file), you’ll see that clicking on “Click here” will print “Triggered” once, and “Or here” twice. I don’t understand why.

What am I doing wrong ?

  • 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-06-03T12:42:18+00:00Added an answer on June 3, 2026 at 12:42 pm

    I get the same incorrect result as you on Windows 7 x64 using Qt 4.8.1. This certainly seems like a bug.

    There was a bug reported and fixed for what appears to be the same behavior on Mac OS X. Although it has been closed, there is a single comment on it that they observed this problem on Windows 7.

    I think filing a new bug report would be a good idea.

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

Sidebar

Related Questions

I have a problem that when I click on the image button instead of
My problem is that I can only seem to click the button once, if
The problem is that this ball after it is dragged and exited click, it
I have a problem in Jquery that whenever I click on checkbox and click
Original demo http://jsfiddle.net/anglimass/NVTzx/9/ Updated demo (that actually demonstrates the problem) http://jsfiddle.net/NVTzx/16/ Please click see
I made a list such that every time I click on an item, it
I using jQuery-UI sortable which works fine. The problem that I am having is
i m using yootheme joomla template in joomla 1.5.x, my problem is that i
I have an application that logs clicks by users. The problem is, these clicks
the problem that im having is this that i am able to create a

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.