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
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: newbe question about signals / slots

    I think your situation is completely different. You just want to access a method (emit a signal) from an object you don't have a pointer to. Just make the pointer available somewhere so that the callback can access it and that's it. You don't need any special external or additional objects or any other kind of special treatment.

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

    Default Re: newbe question about signals / slots

    Yes, juts call the slot from the interface in incomingCallFunc. No need to emit the signal. Make your main window available in incomingCallFunc and simply call the slot (which now doesn't necessarily needs to be a slot ).

    Regards

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

    Default Re: newbe question about signals / slots

    OMG

    That really sounds very easy for me. But i think it isn't as easy for me to implement.

    Okay, let me try:

    I generate a pointer which points to my object usc_gui. This object is created in main.

    main.cpp

    Qt Code:
    1. #include <pjlib.h>
    2. #include <pjlib-util.h>
    3. #include <pjmedia.h>
    4. #include <pjmedia-codec.h>
    5. #include <pjsip.h>
    6. #include <pjsip_simple.h>
    7. #include <pjsip_ua.h>
    8. #include <pjsua-lib/pjsua.h>
    9.  
    10. #include <QApplication>
    11.  
    12. #include "uscsippart.h"
    13. #include "uscgui.h"
    14. #include "uscinterface.h"
    15.  
    16. int main(int argc, char *argv[])
    17. {
    18. init_sip();
    19.  
    20. QApplication uscguiapp(argc, argv);
    21. UscGuiES01 usc_gui;
    22. usc_gui.show();
    23.  
    24. return uscguiapp.exec();
    25.  
    26. }
    To copy to clipboard, switch view to plain text mode 

    Via the parameters I give the callback function the pointer and in the function I can do anything with the object.

    For example:
    Qt Code:
    1. void incomingCallFunc(Usc_Gui_ES01 *to_usc_gui)
    2. {
    3. *to_usc_gui.acceptButton->setEnabled(true);
    4. *to_usc_gui.hangupButton->setEnabled(true);
    5. }
    To copy to clipboard, switch view to plain text mode 

    But where I call this function, the pointer also must be known there?

    Qt Code:
    1. incomingCallFunc(&to_usc_gui);
    To copy to clipboard, switch view to plain text mode 

    Where and how must I define and/or declarate the pointer that it works?

    Best Regards,...

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

    Default Re: newbe question about signals / slots

    You should really learn a bit of C++... Your problem is strictly programming language related.

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

    Default Re: newbe question about signals / slots

    Okay!!

    Many thanks to you!!

    I will learn C++!!!

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

    Default Re: newbe question about signals / slots

    Please read about scopes and declarations of external variables. This should allow you to solve the problem yourself.

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.