Reputation: 41447
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?
Upvotes: 0
Views: 904
Reputation: 155
One additional possibility which I just took about a day to solve in my own code:
Upvotes: 1
Reputation: 656
A couple of other possibilities:
1) The object you are emitting the signal from is blocked (see QObject::blockSignals())
2) The receiver has no thread affinity. If the thread object that the receiver was created in goes away and the receiver isn't moved to another thread, it won't process events (slots being a special case).
Upvotes: 1
Reputation: 949
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
Upvotes: 1