How to convert a horizontal model to a vertical model?
Hi,
I have a horizontal table model with [1 row x 7 columns].
I'd like to make a proxy model to it, which will be a vertical [7 rows x 1 column] model.
Someone suggests me to use QIdentityProxyModel, but I have no idea further.
Would somebody please give me advises?
Many thanks in advance.
Jong Hwang
Re: How to convert a horizontal model to a vertical model?
Re implement columnCount, rowCount, and data functions of your inherited qidentityproxyModel...
Code:
int MyIdentityProxyModel::columnCount(...) const {
return sourceModel()->rowCount();
}
int MyIdentityProxyModel::rowCount(...) const {
return sourceModel()->columnCount();
}
{
if (role != Qt::DisplayRole) return QIdentityProxyModel::data(idx, role);
QModelIndex srcIdx
= sourceModel
()->index
(idx.
column(), idx.
role());
return srcIdx.data();
}
This is not tested code. But just to give you an idea.
Re: How to convert a horizontal model to a vertical model?
Thank you very much for your quick and helpful info.
Jong Hwang
Re: How to convert a horizontal model to a vertical model?
Example in the wiki: [wiki]Transpose proxy model[/wiki]
Re: How to convert a horizontal model to a vertical model?
Thank you very much.
I was about to pull my hair out.
You saved my life. :)