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. SIGNAL_SLOT - Unused connect cost?
Forum Updated to NodeBB v4.3 + New Features

SIGNAL_SLOT - Unused connect cost?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.0k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    maximus
    wrote on last edited by
    #1

    Hi,

    This is a general Qt question, does it "cost" something to do a connect on two QObject, (memory, error possibilities, ..)?

    The reason i'm asking is that I have a lot of connect to do, I could do less because a lot of time the SIGNAL is not used in particular use case, so I could do (if, elseif) and connect only the necessary QObject together.. However this mean more coding and if it's not usefull I will just connect all the possible QObject together.

    Hope i'm clear, thanks!

    code sample :
    @ /// WorkoutPlot_Hr
    connect(this, SIGNAL(updateHrCurve(double, int)), ui->widget_workoutPlot_HeartrateZoom, SLOT(updateCurve(double, int)) );
    connect(this, SIGNAL(targetHrChanged(int, int)), ui->widget_workoutPlot_HeartrateZoom, SLOT(targetChanged(int, int)) );
    /// InfoBox HR
    connect(this, SIGNAL(targetHrChanged(int, int)), ui->widget_infoBoxHr, SLOT(targetChanged(int, int)) );
    connect(dataWorkout, SIGNAL(maxHrIntervalChanged(double)), ui->widget_infoBoxHr, SLOT(maxIntervalChanged(double)) );
    connect(dataWorkout, SIGNAL(maxHrWorkoutChanged(double)), ui->widget_infoBoxHr, SLOT(maxWorkoutChanged(double)) );
    connect(dataWorkout, SIGNAL(avgHrIntervalChanged(double)), ui->widget_infoBoxHr, SLOT(avgIntervalChanged(double)) );
    connect(dataWorkout, SIGNAL(avgHrWorkoutChanged(double)), ui->widget_infoBoxHr, SLOT(avgWorkoutChanged(double)) );@


    Free Indoor Cycling Software - https://maximumtrainer.com

    1 Reply Last reply
    0
    • X Offline
      X Offline
      Xander84
      wrote on last edited by
      #2

      I don't know any specifics but I guess if you do an "emit" call if will just invoke all the slot functions, so there is a cost, but usually nothing more than a simple function call with direct connections. If you never emit a signal there should be no cost at all, of course the connection itself will be stored in memory but that should only be a few bytes, so unless you have millions of connection it should not matter much!?

      if you have many unused connections maybe you can do a "delayed connect", before you do the first emit connect the objects there, if possible?

      I don't know if there is any good and easy way to determine if a signals has any connections before you do the emit, I would like to know that too :)

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maximus
        wrote on last edited by
        #3

        Thanks for the info Mr.Fallout!

        I guess i'll just do all the connect blindly then, just wanted to make sure it wasn't too costly :)


        Free Indoor Cycling Software - https://maximumtrainer.com

        1 Reply Last reply
        0

        • Login

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