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.
class ClipboardInterface
{
public:
virtual void cut() = 0;
virtual void copy() const = 0;
virtual void paste() = 0;
};
class ClipboardEvents
{
public:
virtual void copyAvailableChange(bool available) = 0;
virtual void pasteAvailableChange(bool available) = 0;
};
class ClipboardWrapper
: public QObject,
public ClipboardInterface,
public ClipboardEvents
{
Q_OBJECT
public:
public slots:
void cut() { wrappedObject->cut(); }
void copy() const { wrappedObject->copy(); }
void paste() { wrappedObject->paste(); }
signals:
void copyAvailableChange(bool available);
void pasteAvailableChange(bool available);
private:
ClipboardInterface *wrappedObject;
};
class CustomWidget
: public QWidget,
public ClipboardInterface
{
Q_OBJECT
public:
void cut();
void copy() const;
void paste();
private:
ClipboardWrapper *wrapper;
};
class ClipboardInterface
{
public:
virtual void cut() = 0;
virtual void copy() const = 0;
virtual void paste() = 0;
};
class ClipboardEvents
{
public:
virtual void copyAvailableChange(bool available) = 0;
virtual void pasteAvailableChange(bool available) = 0;
};
class ClipboardWrapper : public QObject,
public ClipboardInterface,
public ClipboardEvents
{
Q_OBJECT
public:
ClipboardWrapper(QObject *parent);
public slots:
void cut() { wrappedObject->cut(); }
void copy() const { wrappedObject->copy(); }
void paste() { wrappedObject->paste(); }
signals:
void copyAvailableChange(bool available);
void pasteAvailableChange(bool available);
private:
ClipboardInterface *wrappedObject;
};
class CustomWidget : public QWidget,
public ClipboardInterface
{
Q_OBJECT
public:
CustomWidget(QWidget *parent = 0);
void cut();
void copy() const;
void paste();
private:
ClipboardWrapper *wrapper;
};
To copy to clipboard, switch view to plain text mode
Bookmarks