python - QTreeView change column name -
i'm working qtreeview , qfilesystemmodel. how can change column name?
this sample of code:
startdir = "/home/abusquets/cads" filter = ["*.dxf"] model = qtgui.qfilesystemmodel() model.setfilter(qdir.alldirs | qdir.nodotanddotdot | qdir.allentries) model.setrootpath(startdir) #només volem fitxers dxf model.setnamefilters(filter) model.setnamefilterdisables(0) tree = qtgui.qtreeview() tree.setmodel(model) tree.setselectionmode(qtgui.qabstractitemview.multiselection) tree.setrootindex(model.index(startdir)) self.setcentralwidget(tree)
in qstandarditemmodel, can it:
model->setheaderdata(0,qt::horizontal, "---header0---");
but, in qfilesystemmodel,
headerdata ( int section, qt::orientation orientation, int role = qt::displayrole ) const
was reimplemented.
methord 1
you need new class inherited qfilesystemmodel, , reimplemente
headerdata()
again.
methord 2
use delegate model
methord 3
set header model independently.
qstandarditemmodel *model1=new qstandarditemmodel(0,5,this); model1->setheaderdata(0, qt::horizontal, "header0"); model1->setheaderdata(1, qt::horizontal, "header1"); tree->header()->setmodel(model1);
the last method simple.
Comments
Post a Comment