class CloneAction
: public QAction { Q_OBJECT
public:
connect(original, SIGNAL(changed()), this, SLOT(updateMe())); // update on change
connect(original, SIGNAL(destroyed()), this, SLOT(deleteLater())); // delete on destroyed
connect(original, SIGNAL(triggered()), this, SLOT(trigger())); // trigger on triggered
// repeat with toggled, etc.
// connect the other way round as well if it makes sense - depends if you want one way or two way relation
m_orig = original;
}
private slots:
void updateMe(){
setProperty(qPrintable(prop), m_orig->property(qPrintable(prop)));
}
private:
};
class CloneAction : public QAction {
Q_OBJECT
public:
CloneAction(QAction *original, QObject *parent = 0) : QAction(parent){
connect(original, SIGNAL(changed()), this, SLOT(updateMe())); // update on change
connect(original, SIGNAL(destroyed()), this, SLOT(deleteLater())); // delete on destroyed
connect(original, SIGNAL(triggered()), this, SLOT(trigger())); // trigger on triggered
// repeat with toggled, etc.
// connect the other way round as well if it makes sense - depends if you want one way or two way relation
m_orig = original;
}
private slots:
void updateMe(){
static QStringList props = QStringList() << "text" << "iconText" << "enabled" << ...;
foreach(const QString prop, props)
setProperty(qPrintable(prop), m_orig->property(qPrintable(prop)));
}
private:
QAction *m_orig;
};
To copy to clipboard, switch view to plain text mode
Bookmarks