Results 1 to 6 of 6

Thread: Access a class without using Signals/Slots

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Access a class without using Signals/Slots

    Well, the connect call doesn't translate to much, but if we add a signal emit also, you'll get something like this:

    Qt Code:
    1. CLASS B;
    2. CLASS A
    3. {
    4. public:
    5. B *bptr;
    6. void somefunc();
    7. };
    8.  
    9. CLASS B
    10. {
    11. public:
    12. slotReturnUserInput(QString qs1, QString qs2);
    13. };
    14.  
    15. void A::somefunc()
    16. {
    17. bptr->slotReturnUserInput("sometext","sometext");
    18. }
    19.  
    20. void B::slotReturnUserInput(QString qs1, QString qs2)
    21. {
    22. some code
    23. }
    To copy to clipboard, switch view to plain text mode 

    Personally however, if your going along that route, I'd use "getUserInput" in class A and get class B to call it, rather than having class A call back class B, which is just nasty and not self-contained.

  2. The following user says thank you to squidge for this useful post:

    impeteperry (10th January 2010)

Similar Threads

  1. How to access the UI from another class ?
    By fitzy in forum Qt Programming
    Replies: 22
    Last Post: 20th July 2016, 14:21
  2. regarding signals/slots
    By jjbabu in forum Qt Programming
    Replies: 2
    Last Post: 4th October 2007, 09:32
  3. Signals and slots
    By sylvarant in forum Newbie
    Replies: 4
    Last Post: 11th September 2007, 15:48
  4. Replies: 5
    Last Post: 14th July 2006, 22:42
  5. help with signals and slots
    By superutsav in forum Qt Programming
    Replies: 3
    Last Post: 4th May 2006, 12:49

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.