Qt QListView with different delegates per column -
the delegate system not clear me now.
i have qlistview displaying custom model.
my model composed following columns:
column 1, 2 , 3 text column, column's item's text filled using
qabstractitem::settext();
column 4, 5, 6 , 7 qvariant of custom class. these column have items filled
qabstractitem::setdata(qvariant::fromvalue(mycustomclass());
what need qlistview display text on column 1,2 , 3, , display custom qstring obtained method of mycustomclass on clumns 4,5,6 , 7.
how can achieve that?
use qabstractitemview::setitemdelegateforcolumn(int column, qabstractitemdelegate* delegate)
, docs.
have got custom model? if pulling out of custom data text, easier reimplement qabstractitemmodel::data(const qmodelindex& index, int role) const
, query column index
is, , if custom data column return display role custom data text; otherwise call parent implementation.
Comments
Post a Comment