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

How to detect when an item in the table view has been modified?

I have this table view in which I add different items on 3 columns. The items are editable so I can modify them directly in the view. bool ClothoidTableModel::setData(const QModelIndex &index, const QVariant &value, int role) { if…
schmimona
  • 849
  • 3
  • 20
  • 40
0
votes
0 answers

Display data from a text file into QAbstractTableModel

I have data that is stored in the a text file and I want to load the lines of the text file into a table model. The class that is derived from QAbstractTableModel uses the following functions: QVariant DataTableModel::headerData(int section,…
taathy
  • 155
  • 1
  • 1
  • 9
0
votes
0 answers

Filter checked checkboxes

By this I tried to make a minimal reproducible example of what I now have. Using QSortFilterProxyModel() to find text and a custom SortFilterProxyModel to show all the selected checkboxes. It looks like both proxy's conflicting eachother and giving…
0
votes
0 answers

PySide6 QAbstractTableModel not updating on dataChanged

Problem at hand I a created a QAbstractTableModel to display a pandas dataframe which in turn is populated from a CSV file. In practice this application will be running in a CPython environment in a .NET application, but for now I am developing in…
Jonathan
  • 748
  • 3
  • 20
0
votes
0 answers

PyQt5 - Model/View - allow user to request undisplayed data

How can I use pyqt5's model-view concept to allow a user access to a 'hidden' column in a view? I often subclass QAbstractTableModel to show a Pandas DataFrame in PyQt5. (h/t to posts on this site). See a MRE below. In using that model (but I am…
10mjg
  • 573
  • 1
  • 6
  • 18
0
votes
0 answers

How can I connect a change in QAbstractTableModel to trigger a function

I use QTableView to display a QAbstractTableModel. I edited the QAbstractTableModel so that I can edit the cells, when displayed. The editing in the window works perfectly, but I want to connect the data change to trigger a function, that takes the…
Mazze
  • 383
  • 3
  • 13
0
votes
0 answers

QAbstractTableModel not updating on editing table cell in QTableView

Im using PyQt5 to develop an MVC application using sqlite DB. I have a custom model inheriting from QAbstractTableModel. For the view im using in QTableView. In the custom model i have added function setdata() and flags() needed to make the table…
BizBaker
  • 13
  • 4
0
votes
1 answer

Format selected columns in QAbstractTableModel from large pandas dataframes

The code below produces a QTableView that is generated from a Pandas DataFrame. columns A and B contain int values, C contains a list of ints for each cell. This currently is displayed as int values. My question is, how do I make columns B and C…
RMRiver
  • 625
  • 1
  • 5
  • 19
0
votes
1 answer

Updating QTableView on the fly when data source changes with a QSortFilterProxyModel in between

I'm trying to update a QTableView when the data source (Pandas Dataframe) changes. I'm using a QAbstractTableModel as the "base" table model and a QSortFilterProxyModel to do some filtering. Somewhen during runtime the data source changes. According…
0
votes
1 answer

Columns not properly moving in QTableView (QAbstractTableModel) using beginMoveColumns?

I am trying to use beginMoveColumns to move a single column over in a QTableView, but it doesn't work properly in my example below. The cell selections get shuffled and column widths don't move. Moving rows using the same logic seems to work…
pyjamas
  • 4,608
  • 5
  • 38
  • 70
0
votes
0 answers

How to add QComboBox to the first row of a QAbstractTable?

I would like to add QComboBox with inputs (Id, Name, Year) to the first row of QAbstractTableModel? I tried similar posts How to set data to QComboBox using QAbstractTableModel (Model/View)? and How to add "Select one..." to QComboBox when using…
0
votes
1 answer

Alerting QDataWidgetMapper to changes when using a custom Model & Delegate

I'm using a subclassed QAbstractTableModel with dataclasses as items. Each dataclass contains a field "field1" with a list, which I'd like to display in a listview and have it automatically change whenever I edit or add an item in the listview. To…
0
votes
0 answers

Qt remove row from custom QAbstractListModel does not work

In the following you'll find my custom model. I reduced it to the just necessary things: class myClass : public QAbstractListModel { Q_OBJECT enum Role { id=Qt::UserRole, call, name, date, time, …
Matthias
  • 135
  • 10
0
votes
1 answer

QTableView dynamic row heigh for large QAbstractTableModel

I know there have been a lot of times question was answered on stackoverflow about how to set row height for QTableView. I'm asking one more time but my question is not exactly about "how", at least not so simple. I'm setting row height successfully…
StarterKit
  • 488
  • 4
  • 15
0
votes
1 answer

Update QAbstractTableModel when combobox changed

I am trying to update my model when a combo box is changed. I have a function connected to the combobox that updates the model but from this question - "the delegates should use the base functions of the model whenever they provide standard behavior…