It doesn't have to be a button. It has to be a signal 
For example:
Q_OBJECT
public:
void someMethod(){ if(something>10) emit someButtonEnableStateChanged(something==20); }
signals:
void someButtonEnableStateChanged(bool);
};
//...
SomeClass *sc = new SomeClass(this);
connect(sc, SIGNAL(someButtonEnableStateChanged(bool)), someotherForm->button78, SLOT(setEnabled(bool)));
class SomeClass : public QObject{
Q_OBJECT
public:
SomeClass(QObject *p=0) : QObject(p){}
void someMethod(){ if(something>10) emit someButtonEnableStateChanged(something==20); }
signals:
void someButtonEnableStateChanged(bool);
};
//...
SomeClass *sc = new SomeClass(this);
connect(sc, SIGNAL(someButtonEnableStateChanged(bool)), someotherForm->button78, SLOT(setEnabled(bool)));
To copy to clipboard, switch view to plain text mode
Better yet, that class which owns the button should have some slot which will handle those changes and the "source" class should just emit signals like "myStateChanged" and not "pleaseChangeTheStateOfSomeOfTheButtonsOfYours ".
Of course another way is to ignore signals and slots and store a pointer to that button in the class which is to manipulate it.
Bookmarks