Reputation: 2695
When I edit cells cellChanged is not called. What did I do wrong?
class QTableWidgetDerived : public QTableWidget
{
Q_OBJECT
//...
protected:
void cellChanged(int row, int column)
{
//...
}
//...
};
class QTableWidgetDerived : public QTableWidget
{
Q_OBJECT
public:
//...
void f(int, int);
protected:
void cellChanged(int row, int column)
{
//...
}
//...
};
connect(this, SIGNAL(cellChanged(int, int)), this, SLOT(f(int, int)));
This does not work. What is wrong?
Upvotes: 1
Views: 116
Reputation: 53215
When I edit cells cellChanged is not called. What did I do wrong?
It cannot be called, only emitted sine it is a signal and not a method or slot.
Respectively, when you subclass QTableWidget
, you do not need to put the declaration into your class.
Furthermore, your connect usage is wrong. You are trying to use it outside the class which is wrong. I suggest to put that into an actual method, otherwise it will not even compile.
Also, while it is not a compilation error not to use the arguments from cellChanged in your slot, you may wish to revisit that decision based on your use case.
Furthermore, your slot is not marked as slot, just a regular public method in your class declaration. You would need to change it to something like this, otherwise, again, it will not be acceptable and you will likely get runtime issues which is probably your issue in here:
public slots:
void f();
Upvotes: 1
Reputation: 949
void cellChanged(int row, int column)
is a SIGNAL, not a virtual function you can override. Just connect the SIGNAL to a SLOT and go on.
Upvotes: 1