Questions tagged [qabstracttablemodel]

QAbstractTableModel is a class in Qt for models that represent their data as a two-dimentional array of items.

The QAbstractTableModel class can't be used directly, but one can subclass his own class from it to represent a specific Table Model. However, the interface of this class is more specialized than QAbstractItemModel, so your derived classes can't be used in tree views.

A list of functions that need to be implemented when subclassing QAbstractTableModel includes:

  • rowCount()
  • columnCount()
  • data()
  • headerData()
  • setData()1
  • flags()1
  • insertRows()2
  • removeRows()2
  • insertColumns()2
  • removeColumns()2

1: for models that support editing.

2: for models with resizable data structure.

Official documentation is available here.

202 questions
0
votes
1 answer

Issue rendering the selected cell on a QTableView

I have a custom QTableView and a custom QAbstractTableModel. The view only allows single selections. I'm trying to customize the background color of the selected cell under some conditions with no success. I expected to do it by combining the data…
Vicent
  • 5,322
  • 2
  • 28
  • 36
0
votes
1 answer

QItemDelegate: painting an unwanted QCheckBox

I have an editable model, which inherits QAbstractTableModel. Also have a custom delegate to go with it. This is my first editable model, and I think I'm missing something. I'm pretty much following the examples found at Nokia. My model tells the…
kiss-o-matic
  • 1,111
  • 16
  • 32
0
votes
0 answers

Qt TableModel with not ready data

So, I have QTableView in my dialog, subclassed QAbstractTableModel, and a list of URLs of images to show using Qt::DecorationRole. Data called by reimplemented MyModel::data(const QModelIndex &index, int role) const method. I can load an image using…
While True
  • 423
  • 2
  • 15
0
votes
1 answer

QTableView/custom table model: set text color in header

My custom table model derives from QAbstractTableModel and is then displayed in a QTableView. Looks like this: I would like to change the text color for certain row headers, which can be decided in the model. Is it possible to color certain headers…
TeaOverflow
  • 2,468
  • 3
  • 28
  • 40
0
votes
1 answer

QTableView - add named row

Im using a using a QTableView in conjuction with table model derived from QAbstaractTableModel. Now I want to insert rows/columns (which represent states/input chars) but I need to pass a string as a label (which is then shown in the HeaderView) for…
TeaOverflow
  • 2,468
  • 3
  • 28
  • 40
0
votes
1 answer

Qt QAbstractModel: remove checkbox

I started to learn Qt, and I would like to implement a table filled with data via QTableView. My problem is, that I don't know how to remove the checkboxes from the cells. It seems like they are put in by default. However, I read that I had to…
VRTuomi
  • 27
  • 7
-2
votes
1 answer

Is it possible to add dict() or list() to insertRows() in QTreeView

I have this TreeItem: class QJsonTreeItem(object): def __init__(self, data, parent=None): self._parent = parent self._key = "" self._value = "" self._type = None self._children = list() self.itemData = data ... def…
Leonid
  • 34
  • 5
1 2 3
13
14