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 8080681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:29:24+00:00 2026-06-05T16:29:24+00:00

I am using one signal and slot connection in a block. My code as

  • 0

I am using one signal and slot connection in a block. My code as follows

in a.cpp

{
 QObject::connect(m_ptheFlange2Details,SIGNAL(GetFlang1DimAfterAnalysis()),
                 this,SLOT(GetFlang1DimAftrAnalysis()));

 m_ptheFlange2Details->get();// one function inside which i am emiting
                             // GetFlang1DimAfterAnalysis() signal ;

 QObject::disconnect(m_ptheFlange2Details,SIGNAL(GetFlang1DimAfterAnalysis()),
                     this,SLOT(GetFlang1DimAftrAnalysis()));

}

Inside the get() function when this emit statement executes, the slot is called lots of times. Where as according to me it should call only once.

  • 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-05T16:29:25+00:00Added an answer on June 5, 2026 at 4:29 pm

    As stated in some of the comments, this is usually caused by calling the connect more the once. The slot will be called once for every time the connection is made. For example, the following code will result in slot() being called 3 times when signal() is emitted once.

    connect(obj, SIGNAL(signal()), obj2, SLOT(slot()));
    connect(obj, SIGNAL(signal()), obj2, SLOT(slot()));
    connect(obj, SIGNAL(signal()), obj2, SLOT(slot()));
    

    If you are doing connects in code that may be run more than once, it is generally a good idea to use Qt::UniqueConnection as the 5th parameter. The following code will result in slot() being called 1 time when signal() is emitted once.

    connect(obj, SIGNAL(signal()), obj2, SLOT(slot()), Qt::UniqueConnection);
    connect(obj, SIGNAL(signal()), obj2, SLOT(slot()), Qt::UniqueConnection);
    connect(obj, SIGNAL(signal()), obj2, SLOT(slot()), Qt::UniqueConnection);
    

    I’m guessing the reason your code is not working correctly is because you are omitting the 5th parameter and connect defaults to Qt::DirectConnection (for single threaded programs). This immediately calls the slot as if it were a function call. This means that it is possible for connect to be called again before the disconnect happens (if there are loops in your program).

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

Sidebar

Related Questions

In Qt, one can connect a signal to a slot using: connect(x, SIGNAL(S()), y,
I'm currently using the JTransforms-library to calculate the DFT of a one-second signal at
My program has one thread class. The signal and the slot both are in
When using one of the various JDBC template methods I am confused on how
I am using one master page.In that I am registering java scripts and checking
I am using one of snook.ca script for simple slideshow. Here it is in
When you move beyond using one instance for your database, what is the best
I am using one UIViewController as shown: @interface RssViewController : UIViewController <UITableViewDataSource,UITableViewDelegate,BlogRssParserDelegate> I am
if pictures are uploaded using one style, how can i change the style of
I'm using one of the nightly resharper builds and recently I just came across

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.