Results 1 to 2 of 2

Thread: How to connect?

  1. #1

    Default How to connect?

    How do I connect these slots and signals? The document I got the code from never explained that part, and so far I just crash my program trying.

    Qt Code:
    1. class ClipboardInterface
    2. {
    3. public:
    4. virtual void cut() = 0;
    5. virtual void copy() const = 0;
    6. virtual void paste() = 0;
    7. };
    8.  
    9. class ClipboardEvents
    10. {
    11. public:
    12. virtual void copyAvailableChange(bool available) = 0;
    13. virtual void pasteAvailableChange(bool available) = 0;
    14. };
    15.  
    16. class ClipboardWrapper : public QObject,
    17. public ClipboardInterface,
    18. public ClipboardEvents
    19. {
    20. Q_OBJECT
    21.  
    22. public:
    23. ClipboardWrapper(QObject *parent);
    24.  
    25. public slots:
    26. void cut() { wrappedObject->cut(); }
    27. void copy() const { wrappedObject->copy(); }
    28. void paste() { wrappedObject->paste(); }
    29.  
    30. signals:
    31. void copyAvailableChange(bool available);
    32. void pasteAvailableChange(bool available);
    33.  
    34. private:
    35. ClipboardInterface *wrappedObject;
    36. };
    37.  
    38. class CustomWidget : public QWidget,
    39. public ClipboardInterface
    40. {
    41. Q_OBJECT
    42.  
    43. public:
    44. CustomWidget(QWidget *parent = 0);
    45.  
    46. void cut();
    47. void copy() const;
    48. void paste();
    49.  
    50. private:
    51. ClipboardWrapper *wrapper;
    52. };
    To copy to clipboard, switch view to plain text mode 

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

Similar Threads

  1. Connect Problem
    By nrabara in forum Newbie
    Replies: 3
    Last Post: 4th May 2009, 12:19
  2. Application only 'animates' once
    By arkain in forum Qt Programming
    Replies: 7
    Last Post: 29th April 2009, 08:09
  3. A signal/slot connect isn't working.
    By Daimonie in forum Qt Programming
    Replies: 6
    Last Post: 15th February 2009, 22:55
  4. Replies: 12
    Last Post: 18th September 2008, 15:04

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.