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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:45:51+00:00 2026-06-04T00:45:51+00:00

I was wodering if it matter where the connection is made on an object.

  • 0

I was wodering if it matter where the connection is made on an object. For example, usally I do it before I make the call that might emit signals, but sometimes I have to do it afterwards if it’s node on for example a QNetworkReply that doesnt exists until the call is made. Maybe I have to make some checks as well before the connection can be made.

Is there any chance that the signal can be emitted BEFORE a connection was made to connect this signal to a slot?

For example:

ClassA::function() {

   ClassB b;

   b.someCall();

   connect(&b, SIGNAL(finished()), this, SLOT(someSlot()));
}

ClassB::someCall() {

    emit finished();

}

Would the slot be called here? This might not be a very practical example since you would probabbly just use a return value in this case. But in some cases I do this, for example if “someCall” is a routine that you can step though and it can fail, either if a network-request inside of that routine fails, or if we get some error right in the beginning. Either way, the “failed()” signal should be emitted and have a slot to handle any kind of failure. For example;

ClassB::someCall() {

   allocate "something"

   if(something == NULL) emit finished();


   QNetworkReply *reply = someNetworkAccessManager.put(something);

   connect(reply, SIGNAL(finished()), this, SIGNAL(finished())); 

}

So here we have a call where it can emit finished() pretty much straight away, or after a while. If I create the connection after I make this call, will the first finished() be catched?

  • 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-04T00:45:53+00:00Added an answer on June 4, 2026 at 12:45 am

    No, moc handles the connect macro’s for QT, and creates all the underpinnings necessary to do the magic of signals and slots. as long as the visibility of where moc adds the code to the project is within scope of the compiler when its trying to resolve function calls, all will be well. And in practice, we put those connect calls as early on as possible, ie after an object is declared, and before it’s used, in the header.

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

Sidebar

Related Questions

So it's not a complicated matter at all, but was wondering how the Stackoverflow
I have an onClickListener that triggers a network call so I would like to
The equals() method (and for that matter, also the compareTo() method) can become a
no matter what day I call the function on. I know I could write
I keep reading about ping/pong messages in websockets to keep the connection alive, but
Wondering if there is any way to get the lambda expressions that result from
Wondering if anyone can suggest a good file replication tool that will replicate across
Wondering if there is a good way to generate temporary URLs that expire in
I'm using Apache Commons to make my HTTP calls, and in my activity I
There is a JDK function that, although the javadocs does not declare it as

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.