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
1
vote
2 answers

How to use multiline text / linebreaks in QTableView/QAbstractTableModel?

I have subclassed QAbstractTableModel and QTabelView (and QSortFilterProxyModel) and I'd like to allow multi-line text to be displayed to and entered by the user in text cells (currently, hitting return will confirm the edit instead of inserting a…
basic6
  • 3,643
  • 3
  • 42
  • 47
1
vote
2 answers

Qt: Signal while a QTableView item data is being edited instead of after edit is done?

I have a QTableView which has some QString based items in its model. I implemented setData in my table model, so editing is working (I can change the data in the cell, setData is called to update the model, and the table is properly…
Jettoblack
  • 125
  • 3
  • 8
0
votes
3 answers

QAbstactTableModel insert at top

I have addFile function in my TableModel class which inserts a new record at the end. void TableModel::addFile(const QString &path) { beginInsertRows(QModelIndex(), list.size(),list.size()); TableItem item; item.filename = path; …
Hiren
  • 341
  • 1
  • 4
  • 17
0
votes
1 answer

How to Filter a QAbstractTableModel model

I have created a QAbstractTableModel model called tableModel and QAbstractListModel model called listModel andi have set these model to respective views (QTableView and QListView).I want to filter the tableModel based on the listModel.That mean when…
user671253
0
votes
2 answers

c++ qt qabstracttablemodel subclass chrashes when underlying qmap is updated

i am having great trouble with the update of a custom qabstracttablemodel. i want to have a tableview that shows the prices of several stocks. i get the prices from a local server i control. this setup is for testing purposes. the pricing…
MicroPor
  • 1
  • 3
0
votes
0 answers

QSortFilterProxyModel - not updating

I am trying to use QTableView with a custom model and QSortFilterProxyModel. If I set the base model: self.setModel(self._model) the table displays correctly. However, if I set the proxy model: self.setModel(self._proxy_model) no rows are…
Elad Weiss
  • 3,662
  • 3
  • 22
  • 50
0
votes
1 answer

How to handle custom data show in QTableView?

I have a QTableView with custom model, delegate and data class. I want to show different widgets in my table based on data types. this is done in my delegate class. background and checkbox types are handled in show method of my model class. this is…
0
votes
1 answer

removing multiple rows in RemoveRow in QAbstractTableModel and refreshing - Pyside2

I have a QTableView using a QAbstractTableModel and I am trying create some remove row functionality. I have written in the removeRow code like so - def removeRows(self, row, count, parent=QtCore.QModelIndex()): self.beginRemoveRows(parent,…
0
votes
1 answer

How to set a QAbstractTableModel custom class model to the QML TableView

I have created a custom table model Python class, subclassing the QAbstractTableModel and when I try to set the instance of this class, model, to the model property of the TableView, the whole app crashes. There are no error debug info in the…
Nick V
  • 3
  • 2
0
votes
1 answer

Memory Leak in Pyside6 QAbstractTableModel

I have a PySide6 application using an MVC structure. It utilizies two threads. The main thread is the Qt Event loop(GUI). The Model utilizes an asyncio event loop which runs in the other thread. The Model handles all the IO for the application. When…
Rob M.
  • 1
  • 3
0
votes
1 answer

how insertRow to QAbstractTableModel with indexes?

im try to create small app in PyQT that show table from database and user will be able to add new rows and fill them. Table's data taken from pd.dataframe with 2 cols and dates-indexes. New inserted rows must be with new index == last date-index + 1…
papadulo
  • 3
  • 2
0
votes
0 answers

Eliminate the empty spaces in QAbstractTableModel item when cell is checkable

I am trying to implement a custom QTableView. For that I am subclassing QAbstractTableModel such that it takes a list of strings. Here the implementation. class ListTableModel(qtc.QAbstractTableModel): def __init__(self, data: List[List[str]],…
Oier Arcelus
  • 107
  • 1
  • 8
0
votes
0 answers

Increase performance in PYQT6 QAbstractTableModel when using Checkboxes

I'm using PyQT6 for my application. I'm creating my own QAbstractTableModel where each row has some details and last 3 columns are checkboxes representing received, packed, sent. I successfully implemented the solution. The problem is there is a…
Solumath
  • 1
  • 1
0
votes
2 answers

How to implement setData on PyQt5 QAbstractTableModel with QSqlRelationalTableModel

I am newbie with Pyqt and need help with setting setData on QAbstractTableModel with QSqlRelationalTableModel table model I have this simple code and I dont now how to implement setData function. I can't set value to field. I'm getting TypeError:…
0
votes
0 answers

Pandas Model (QAbstractTableModel) binded with PyQt5 QTableView Add Rows not working

I'm using a custom Pandas Model(QAbstractTableModel) which is editable. I'm trying to add rows and then the user should be able to edit them and pass the values to the dataframe. Unfortunately, the example I found from PyQt5: Implement removeRows…
fotiskt
  • 1
  • 2