Move items in a QSortFilterProxyModel
I have a tableview with takes a qsortfilterproxymodel and is filtered by a particular name.
I have subclassed the qsortfilterproxymodel
Code:
{
Q_OBJECT
public:
FilterProxyModel
(QObject *parent
= 0);
void moveUp( const int itemIndex);
void moveDown( const int itemIndex);
};
and here's the implementation
Code:
FilterProxyModel
::FilterProxyModel (QObject *parent
) :{
}
void FilterProxyModel ::moveUp(const int itemIndex)
{
if(itemIndex > 0 && itemIndex < rowCount())
{
itemIndex - 1);
endMoveRows();
}
}
void FilterProxyModel ::moveDown(const int itemIndex)
{
if(itemIndex >= 0 && itemIndex < rowCount() - 1)
{
itemIndex + 2);
endMoveRows();
}
}
Here's how the model implemented
Code:
m_Model = new FilterProxyModel(this);
m_Model ->setSourceModel(partiesModel);
m_Model
->setFilterRegExp
(QRegExp("party", Qt
::CaseInsensitive,
QRegExp::FixedString));
m_Model ->setFilterKeyColumn(PartyModel::Action);
I want to move the items using a push button, when i call the function the move doesn't happen. Could you tell me what I'm missing?
Re: Move items in a QSortFilterProxyModel
Check return value of moveRow() and shows that function.
Re: Move items in a QSortFilterProxyModel
I will write a custom implementation of the move and try