Results 1 to 6 of 6

Thread: SIGNAL SLOT performance

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default SIGNAL SLOT performance

    Hi,

    I have a class containing a list of another class objects. Every child objects are connected to a slot in the parent class.

    It's a good idea to pass the parent pointer to the childs and let the childrens call directly the method of the parent?
    I'm thinking of use this behaviour instead of SIGNALs SLOTs mechanism because it uses a lot of function calls to finally call the method(I'm thinking only on Direct connections).
    My application needs to be as faster as can be possible and so I want to increase the performance.

    Thanks,
    Òscar Llarch i Galán

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SIGNAL SLOT performance

    You can access to the parent widget with method QWidget::parentWidget ().

    SIGNAL/SLOT mechanism allow you to have a responsive GUI.
    If you call directly parent's method you bypass application event loop and then you have to pay attention to the responsiveness of your GUI.
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SIGNAL SLOT performance

    If you are inheriting the class, the functions will be available to you, isnt it ?
    Why do you need to call them separately ?

    And signal/slot arent slow.... are you facing problems with it right now ?

  4. #4
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: SIGNAL SLOT performance

    Hi,

    Thanks, but I never told that the classes are widgets and never told that the child classes are dervied from the first class.

    The class A contains a QList<B*>. So class A contains a list of class B object pointers.
    When a object B is created and inserted to the list I make some connections that when the object of the class B does something it emits a signal to class A. Is more clear now?

    So, is a good idea to pass a parent pointer to the child classes to access direcly to the class A methods or is better to use SIGNAL SLOT mechanism?

    Thanks,
    Òscar Llarch i Galán

  5. #5
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: SIGNAL SLOT performance

    I would use "pass parent pointer to a child", because as was told above, you will use direct calls. but if you don't know anything about parent, i.e. you can't say what kind of objects can be parent then it would be better to implement connection interface between classes using SIGNALS and SLOTS.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  6. #6
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: SIGNAL SLOT performance

    Hi,

    Thanks spirit, it was what I suspect.
    Òscar Llarch i Galán

Similar Threads

  1. pthread instead QThread
    By brevleq in forum Qt Programming
    Replies: 8
    Last Post: 23rd December 2008, 07:16
  2. Connection of custon signals/slots
    By brevleq in forum Qt Programming
    Replies: 2
    Last Post: 23rd December 2008, 07:04
  3. Replies: 12
    Last Post: 18th September 2008, 15:04
  4. Signal & Slot editor
    By Ishark in forum Qt Tools
    Replies: 4
    Last Post: 28th May 2008, 15:20
  5. signal slot conection using a string, not a SLOT
    By rianquinn in forum Qt Programming
    Replies: 6
    Last Post: 5th February 2006, 18:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.