I want to call a function indexChanged()
if an index in my treeView is changed.
I used ui->treeView->currentChanged()
signal but it didn't call indexChanged()
slot, even though I connected the signal to the slot.
Here's my code :
.cpp file
TipManager::TipManager(QWidget *parent) :
QWidget(parent),
ui(new Ui::TipManager)
{
ui->setupUi(this);
connect(ui->treeView->selectionModel(), &QItemSelectionModel::currentChanged, this, &TipManager::indexChanged);
...
}
void TipManager::indexChanged(const QModelIndex ¤t, const QModelIndex &previous)
{
trimCurrentPath(previous);
}
.h file
namespace Ui {
class TipManager;
}
class TipManager : public QWidget
{
Q_OBJECT
public:
explicit TipManager(QWidget *parent = 0);
~TipManager();
public slots:
void indexChanged(const QModelIndex ¤t, const QModelIndex &previous);
private:
Ui::TipManager *ui;
...
};
I also tested in debug mode, but the slot function indexChanged()
is not even called. Plus, it shows this message instead : QObject::connect: invalid null parameter