Results 1 to 3 of 3

Thread: Signals and Slots management

  1. #1
    Join Date
    Nov 2010
    Posts
    2
    Platforms
    MacOS X

    Default Signals and Slots management

    Hello,

    i am currently writing a software which has 2 classes "Robot" and "Camera" each of them represent a real physical devices, i control them each of them with through their own QTcpSocket connection. For example:
    The Robot accepts a set of predefined commands like:
    command: "SetJointsPositiona1 a2 ..a6" returns "true/false"
    command: "GetJointsPosition" returns "a1 .. a6"
    And many many more.
    So since every Response must be handeled differently i have to create for each Command response an own slot. From my MainWindow (where the classes are defined) i emit a signal with "SetJointsPosition..." -> The Robot has a Slot: onSetJointsPositionSlot(QString) where the command is sent to the device. After receiving the answer the robot emits GotJointsPositionSignal(QString) which is connected to the GotJointsPositionSlot(Qstring) in Mainwindow.

    But now come another two classes "Calibration" and "FollowMe".
    In "Calibration" i send a signal to the robot to take some position, after the position is taken i send a signal to camera to check if the position is visible. If it is visible i send again a signal to the camera to acquire the position from camera perspective, and then back to the robot to acquire its position. And i repeat it for like 10 times. The thing is the command sent to the "Robot" or "Camera"

    So you can see that the number of Signals and Slots that i have to write is enormous.

    So here comes my question. How anyone manage this big number of Signals/Slots? How do you handle this kind of class-communication?

    Thanks.

  2. #2
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Signals and Slots management

    Hi,

    why do you use signals/slots at all? Can't you implement your functionality directly using methods? E.g. you could call "onSetJointsPositionSlot" directly. This method could return the QString that is currently emitted by a signal.

    Felix

  3. #3
    Join Date
    Nov 2010
    Posts
    2
    Platforms
    MacOS X

    Default Re: Signals and Slots management

    @Felix,
    well i have reduced many of the functionalities to normal methods, but still many things just must be implemented using signals/slots (and still there are many of them) , for example when executing "FollowMe". the princip is: I hold i marker which is detected by the camera, this position is transformed to Robots position which he then takes. The Camera works like 50frame/s and each time a signal(QMatrix4x4) is sent to the Robot. but the robot must go to the new position after he already taken the old one. And this can take some time. The second thing is that while running FollowMe i should be able to do other actions like: set the speed of the robots joints or switch between follow types(orientation,translation,both) etc..
    So for the robot command like "SetJointsPosition" and its return i have to implement 3 Slots, and emit 3 signals . SetJointsPositionFromMainWindow, SetJointsPositionFromCalibration, SetJointsPositionFromFollowMe. eventhough it is the same code that is executed.

Similar Threads

  1. Help with Signals and slots
    By chetu1984 in forum Newbie
    Replies: 5
    Last Post: 10th March 2011, 22:30
  2. Questions about QThread and Signals management
    By StanOfSky in forum Newbie
    Replies: 9
    Last Post: 6th November 2010, 14:36
  3. about signals and slots
    By Sandip in forum Qt Programming
    Replies: 9
    Last Post: 15th July 2008, 16:02
  4. regarding signals/slots
    By jjbabu in forum Qt Programming
    Replies: 2
    Last Post: 4th October 2007, 09:32
  5. Signals and Slots
    By merry in forum Qt Programming
    Replies: 4
    Last Post: 22nd February 2007, 08:11

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.