I have this class:
class CustomEdit : public QTextEdit
{
Q_GADGET
public:
CustomEdit(QWidget* parent);
public slots:
void onTextChanged ();
};
CustomEdit::CustomEdit(QWidget* parent)
: QTextEdit(parent)
{
connect( this, SIGNAL(textChanged()), this, SLOT(onTextChanged()));
}
void CustomEdit::onTextChanged ()
{
// ... do stuff
}
The onTextChanged
method is never called when I type text into the edit control.
What am I missing?
All classes that contain signals or slots must mention Q_OBJECT at the top of their declaration. They must also derive (directly or indirectly) from QObject.
Try using Q_OBJECT