Can't setHeaderData in class derived from QAbstractTableModel[SOLVED]
General and Desktop
6
Posts
2
Posters
3.1k
Views
2
Watching
-
Hello again.
I tried to create my own model derived from QAbstractTableModel. I have inherited it like that:
class MyTableModel: public QAbstractTableModel { .... public: int rowCount(const QModelIndex& index) const; int columnCount(const QModelIndex& index) const { return 2; } QVariant data(const QModelIndex & index, int role) const; .... }My model is working fine except I can't change the header of row:
MyTableModel model; bool is_change = model.setHeaderData(0, Qt::Horizontal, "Column1"); qDebug() << is_change;All time in console I see "false".
Also I tried reimplement this method with calling headerDataChanged(), but the false answer still exists.Please, help me to change header data)
Thank you -
Hi,
Maybe a silly question but: do you have at least one column in your model ?
-
AFAIK, you can't set a header on a row/column that doesn't exist. The row/column can be empty, but it still needs to exist
-
AFAIK, you can't set a header on a row/column that doesn't exist. The row/column can be empty, but it still needs to exist