Results 1 to 20 of 20

Thread: newbe question about signals / slots

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2007
    Location
    Vienna / Austria
    Posts
    54
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Post newbe question about signals / slots

    Hello!

    At first a have to say:

    .) i am a newb at writing programs in C++
    .) i am a newb at Qt
    .) i am a newb at OOP

    My question: How can I emit a signal out from another function? I think that i have to tedliver someting about the parameters of the functin????

    Imagine: I have a SIP Client in C++ (pjsip.org) and I want to build a Application (GUI) on this Client.

    So when I (the SIP Client) is called, it comes to a callback function in which the call is handeld. Now i want to see it on the GUI when I get called.

    My idea: I program a signal Slot unit:
    Signal: --> is in the Callback function --> incomingCall();
    and in the Slot: --> I enable some buttons for example.

    Qt Code:
    1. #include "uscinterface.h" <-- here in this include it the prototyp of the class which contains the signal
    2.  
    3. static void on_incoming_call(...)
    4. {
    5. ...
    6. ...
    7. ...
    8.  
    9.  
    10. emit incomingCallsignal();
    11. }
    To copy to clipboard, switch view to plain text mode 

    Error message at compiling:

    error: 'incomingCallsignal' was not declared in this scope


    So what is my mistake, or what is the right way to solve this problem
    If you need more information or sourcecode to help me, let me know

    Best Regards,...

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: newbe question about signals / slots

    First of all, signals can only be emitted from objects that inherit QObject.
    You should take a look in the Assistant at "Signals and slots" before starting anything.

  3. The following user says thank you to marcel for this useful post:

    Walsi (19th April 2007)

  4. #3
    Join Date
    Mar 2007
    Location
    Vienna / Austria
    Posts
    54
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: newbe question about signals / slots

    Thanks for your quick answer marcel!

    I read the information about Signals and Slots in the Assistant again, and now I understand it better. So my I idea to solve this porblem isn't possible.

    So, how can I "connect" this Callback function with any element of my GUI???

    I am quite desperate about this problem because I am already working about 4 days on it's solution.

    So it would be very nice if you could help me!

    best Regards,...

  5. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: newbe question about signals / slots

    The callback is called from another application or from the same application?

  6. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: newbe question about signals / slots

    .) i am a newb at writing programs in C++
    .) i am a newb at Qt
    .) i am a newb at OOP
    Welcome!

    Look, if you are new to all three, starting with call back functions is a bit hard.
    Maybe you don't even need that.
    Explain what it is you what to do, maybe the solution is much simpler.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. #6
    Join Date
    Mar 2007
    Location
    Vienna / Austria
    Posts
    54
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: newbe question about signals / slots

    I use the PJSIP Opensource. This is a SIP Client without a GUI.

    There is a good online support on pjsip.org. There is also an example c file which shows how you could start building your own Applicaiton own it.

    I have to build a Application with a GUI (QT4) on it. So I took those sample c file and started modifying and extending it.

    There is a callbackfunction which is called when somebody want to call me!

    Qt Code:
    1. /* Callback called by the library upon receiving incoming call */
    2. static void on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id,
    3. pjsip_rx_data *rdata)
    4. {
    5. pjsua_call_info ci;
    6.  
    7. PJ_UNUSED_ARG(acc_id);
    8. PJ_UNUSED_ARG(rdata);
    9.  
    10. pjsua_call_get_info(call_id, &ci);
    11.  
    12. PJ_LOG(3,(THIS_FILE, "Incoming call from %.*s!!",
    13. (int)ci.remote_info.slen,
    14. ci.remote_info.ptr));
    15.  
    16. /* Automatically answer incoming calls with 200/OK */
    17. pjsua_call_answer(call_id, 200, NULL, NULL);
    18. emit incomingCall();
    19. }
    To copy to clipboard, switch view to plain text mode 

    I know that the application comes to this function when I get called.

    So my first idea was, to rewrite this function so, that it doesn't automatically answer a incoming call but gives any signal to the GUI that I (the user) can see that I am called.

    And afterwards I want to press to button and answer this call.


    Best Regards,...

  8. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: newbe question about signals / slots

    Thie issue (external callback and Qt) has been dicussed here quite a bit.
    So the basic possiblities are in these threads.
    Read a bit, and ask if you need clarifications.
    http://www.qtcentre.org/forum/search.php?searchid=61976
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  9. #8
    Join Date
    Mar 2007
    Location
    Vienna / Austria
    Posts
    54
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: newbe question about signals / slots

    Sorry - no matches. Please try some different terms.

    That comes when i use your link - http://www.qtcentre.org/forum/search.php?searchid=61976


    ??? STRANGE ???


    Instead I read and try to understand this thread: http://www.qtcentre.org/forum/f-qt-p...slot-5998.html


    Best Regards...
    Last edited by Walsi; 20th April 2007 at 06:30.

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

    Default Re: newbe question about signals / slots

    No, it's not strange. Search results are cached for a limited period of time and it just fell out of cache. It's better to give the URL including search terms instead of the result id. I guess the term was probably "callback".

  11. #10
    Join Date
    Mar 2007
    Location
    Vienna / Austria
    Posts
    54
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: newbe question about signals / slots

    wysota wrote in this thread:

    You might register a callback from the callback api and there either call the slot directly or use a dummy QObject that will emit the signal for you.
    Is that the right way to handle my problem?

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

    Default Re: newbe question about signals / slots

    I have no idea, because I don't know what your problem is Looks like it's something different than what the quoted sentence was about.

Similar Threads

  1. Signals and Slots question
    By Thoosle in forum Qt Programming
    Replies: 5
    Last Post: 5th December 2006, 00:24
  2. Nested signals and slots
    By vishva in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2006, 09:47
  3. Signals and Slots in dll
    By ankurjain in forum Qt Programming
    Replies: 8
    Last Post: 29th March 2006, 08:12
  4. Order of signals and slots
    By Morea in forum Newbie
    Replies: 1
    Last Post: 26th February 2006, 22:09
  5. Problem with Signals and Slots
    By Kapil in forum Newbie
    Replies: 11
    Last Post: 15th February 2006, 11:35

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.