Results 1 to 5 of 5

Thread: dynamic signal connecting

  1. #1
    Join Date
    Jul 2008
    Posts
    66
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default dynamic signal connecting

    Hi,

    I have two kind of classes. I use them for dynamically creating of objects at runtime.
    The first one is a QWidget template for the GUI (which holds many widgets), the second one is a simple object(which holds the whole logic/functionality).

    After creating this pair dynamically at runtime I want to connect each signal from classA to the slots of classB and vise versa.
    It is possible that I create many instances of these two classes ( = many pair connections)!

    Pair1ClassA <----->Pair1ClassB
    Pair2ClassA<------>Pair2ClassB .... etc..

    When the user clicks sth. on Pair1ClassAInstance the slot of Pair1ClassBInstance must be called and the same with the other instances...

    Do I need to use the "Dynamic signals and slots" described here
    http://doc.trolltech.com/qq/qq16-dynamicqobject.html ?

    Or is there another, better workaround?

    Something like:
    Connecting two objects and storing this connection somewhere and after that connecting another pair...etc...

    Edit:
    The signals are availalbe in the Classes( no need to create them at runtime).
    The slots too...just connecting at runtime...
    Last edited by donglebob; 18th November 2008 at 07:39.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: dynamic signal connecting

    Can't you use connect()?

  3. #3
    Join Date
    Jul 2008
    Posts
    66
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: dynamic signal connecting

    Quote Originally Posted by wysota View Post
    Can't you use connect()?
    I tried it but somehow its not working when I create a second pair.

    With the first created pair the connection works...I click sth on the gui..the object of ClassB receives it. After that It emits a "IT WORKS!" back to the GUI. Fine!

    But when i create a second pair and connect them the same way the problem appears!
    I click on the first-pairs GUI (QWidget) on the same button like before, the message "IT WORKS!" doesnt appear on the screen of "first-pair". It appears on the newly created one "second pair".

    While connecting I checked the adresses of both. They are different!

    What could be the problem?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: dynamic signal connecting

    Can we see some code?

  5. #5
    Join Date
    Jul 2008
    Posts
    66
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: dynamic signal connecting

    problem is solved now.
    i made a stupid mistake while setting the information at the destination widget.

Similar Threads

  1. Replies: 4
    Last Post: 16th November 2008, 13:53
  2. Connecting signal to button
    By steg90 in forum Qt Programming
    Replies: 8
    Last Post: 13th December 2007, 10:37
  3. Connecting to a base class signal?
    By AaronMK in forum Qt Programming
    Replies: 4
    Last Post: 26th October 2007, 22:37
  4. Connecting signal to form that is closing
    By steg90 in forum Qt Programming
    Replies: 3
    Last Post: 18th May 2007, 07:54

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.