TorAn
6th November 2014, 15:24
I have a QAbstractTableModel-derived model attached to a QTreeView and I need to be able to track user movement of columns in the view. Luckily QAbstractTableModel has a signal "columnsMoved".
So, I do usual stuff:
ui.lstPairs->setModel(&_model);
bool res1 = connect(&_model, SIGNAL(columnsMoved(const QModelIndex&, int, int, const QModelIndex&, int)),
this, SLOT(columnsMoved(const QModelIndex&, int, int, const QModelIndex&, int)));
if (!res1)
return;
..
and slot implementation:
private slots:
void columnsMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationColumn);
..
void viewPairs::columnsMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationColumn)
{
int i =5; // test
}
When I run it in debug the res1 variable is TRUE, so everything looks normal. Then I start moving the view columns using mouse and my slot is never called. (I place a breakpoint in int i = 5; line)
Question: what can be the problem that causes columnsMoved slot to never be called?
Thanks.
So, I do usual stuff:
ui.lstPairs->setModel(&_model);
bool res1 = connect(&_model, SIGNAL(columnsMoved(const QModelIndex&, int, int, const QModelIndex&, int)),
this, SLOT(columnsMoved(const QModelIndex&, int, int, const QModelIndex&, int)));
if (!res1)
return;
..
and slot implementation:
private slots:
void columnsMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationColumn);
..
void viewPairs::columnsMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationColumn)
{
int i =5; // test
}
When I run it in debug the res1 variable is TRUE, so everything looks normal. Then I start moving the view columns using mouse and my slot is never called. (I place a breakpoint in int i = 5; line)
Question: what can be the problem that causes columnsMoved slot to never be called?
Thanks.