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
1 answer

Qt: Updating data in a TableView with QAbstractTableModel

I try to implement a table view with two columns. The right columns shows parameters, which should not be changed by runtime, and left column shows values, that should be updated constantly at runtime. For this I implement a data model (derived from…
taathy
  • 155
  • 1
  • 1
  • 9
1
vote
1 answer

How can I move a row in a QTableView (QAbstractTableModel) using beginMoveRows?

I am trying to move rows in my QTableView in the example below, but am struggling to understand how to correctly call beginMoveRows. My example has 3 buttons to do various row movements, and the 3rd one (move a row down by 1) causes my program to…
pyjamas
  • 4,608
  • 5
  • 38
  • 70
1
vote
1 answer

Why do boolean values create a dropdown menu in QAbstractTableModel?

In my custom model setting a bool value automatically creates a combobox/dropdown menu with True/False options, whereas string values create a regular line edit type of editor. I'm trying to understand why this is? and can I access that editor from…
1
vote
1 answer

Text can be seen behind delegate widgets in QTableView

I have a QTableView that uses QItemDelegate and QAbstractTableModel. A row contains a QPushButton, QCheckBox, QCombobox and QTimeEdit. My issue is that text appears behind the widgets. When a cell containing the QPushButton and QCheckBox are…
1
vote
0 answers

PyQt5 - QTableView + QAbstractTableModel - html format cell/column text

Is there a way, perhaps using QStyledItemDelegate (like here PyQt / Qt, tableview with custom delegate to use ellipsis for text overflowing cell or here QStyledItemDelegate truncates text horizontally and doesn't add a horizontal scroll bar), to…
10mjg
  • 573
  • 1
  • 6
  • 18
1
vote
1 answer

How to undo a change in QAbstractTableModel?

I have this simple example: a value in last column of my QAbstractTableModel equals value in column 1 multiplied by 2. So every time a change is made to value in column 1 - it results to a change in column 2. When the value in the last column has…
Nasty_gri
  • 83
  • 7
1
vote
1 answer

QAbstractTableModel & QTableView with more than one StyledItemDelegateForColumn crashes my app

I have QTableView with QAbstractTableModel and multiple QStyledItemDelegates. I set these delegates by setStyledItemForColumn. In this case, my app crashes. Crash happens when I push 1 key, or try to expand the gui to right. But if I use one of…
Haru
  • 1,884
  • 2
  • 12
  • 30
1
vote
1 answer

With PySide2 and QTableView how do i get multiple delegates in table view using pandas model?

hi i've tried all i can think of and had looked at hundreds of stack overflow questions about tables and delegate's, and scratched my head for hours looking at the documentation trying to understand the c++ language and i have not read anything…
1
vote
1 answer

update dataframe after edited in qTableView Python PyQt5

Good day, I am trying to load a dataframe into a PyQt5 QTableView to allow edit last column with ComboBox. Once the edit is complete, print the dataframe so that I can edit it further. When I click 'print_data' I cannot get the updated QTableView…
actnmk
  • 156
  • 12
1
vote
1 answer

How to make QTableView refresh Background color after it loads data again

i have the following doubt regarding QTableView, i have added some code that changes the row background depending on what string the dataframe contains on the last column. def data(self, index, role=Qt.DisplayRole): if index.isValid(): …
Magthuzad
  • 160
  • 1
  • 1
  • 10
1
vote
1 answer

Insert data after setModel on QAbstractTableModel

My model is a subclass of QAbstractTableModel and I have overridden some methods to make this work. class UserModel: public QAbstractTableModel { Q_OBJECT public: UserModel(QList users, QObject *parent = Q_NULLPTR); int…
user3178486
  • 321
  • 6
  • 17
1
vote
2 answers

Qt update TableView every x seconds

I have a QAbstractTableModel that has a list of custom items it displays, this TableModel is the model of a TableView. How can i refresh the TableView every x seconds? I tried beginInsertRows and endInsertRows, but this caused laggs because im…
Bennet L.
  • 61
  • 7
1
vote
2 answers

Background color a specific table row given row number for QAbstractTableModel in PyQt5

In PyQt5, I am using the model view to display a table. The model is the QAbstractTableModel, and I want to background color say row 0. The coloring works, but all rows get colored, instead of the row that I specified. Also, when I change to…
jxw
  • 586
  • 2
  • 6
  • 36
1
vote
0 answers

QTableView model out of memory

I am getting an out of memory crash when using QTableView + QAbstractTableModel with a large number of items. The problem seems to come from the vertical header view. It tries to allocate a QVector with same size as the row count (150 millions). How…
Octo
  • 543
  • 1
  • 5
  • 16
1
vote
1 answer

PyQt5 TableModel(QAbstractTableModel) shows no data

Hello i started with PyQt5 recently and tried to implement a csv parser: But i struggled with the descendant of the QAbstractTableModel. No data in the view! The tutorial from qt5 (https://doc.qt.io/qt-5/qabstracttablemodel.html) says i have to…
jgsedi
  • 227
  • 4
  • 18