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

Change state of checkbox programmatically in qtableview

I found this model to visualize qtableview with checkboxes. It works, but now I want also to change the state of checkboxes programmatically (for example a button that check/uncheck all checkboxes). I have no idea how I can do it... from…
0
votes
1 answer

pyqt5 Marked line in a different color

I'm using PyQt5 and would like to mark the line with a single click, that is, make it appear in a different color, e.g. in red. After another click on the same line, the marking should be canceled again. I have tried different approaches (how to see…
0
votes
1 answer

How can I amend an object of my model by double clicking on it in the view

I have a QTableView displaying a QAbstractTableModel which represent my list of objects. One attribute of my object is a boolean (isExpired), I just want to modify this attribute when double clicking on the specific cell in the table view. So on…
alaintk
  • 1
  • 1
  • 4
0
votes
2 answers

Pass whole QAbstractTableModel to QML

I have subclassed the QAbstractTableModel. Now I would like to pass to to the QML side. All examples I found expose the override methods of the class using Q_INVOKABLE, ie data or setData. Can the whole QAbstractTableModel object be passed as…
Łukasz Przeniosło
  • 2,725
  • 5
  • 38
  • 74
0
votes
1 answer

Is it possible to link one and the same set of source data with different models of tables?

Suppose I have a source data structure of type QString. My goal is to display this data in different tables (QTableView) presented by different models (QAbstractTableModel). I would like to see the data change in these tables when the source data…
0
votes
1 answer

QTableView show scroll

I am working on Qt application. There I have QTableView which takes its data from QAbstractTableModel. I am using QList to represent each row in the table. My question is, I would like to start showing scroll instead of keep growing table view size…
RuLoViC
  • 825
  • 7
  • 23
0
votes
1 answer

Qt Quick Controls 2 and QAbstractTableModel

I have a model based on QAbstractTableModel that I would like to use to display its content in a list in QML. Actually, I need to display the first column only. TableView does not exist in Qt Quick Controls 2 and suffers from performance issue and…
Denis Rouzaud
  • 2,412
  • 2
  • 26
  • 45
0
votes
0 answers

The table is not displayed

I have a Basic Component class. Other classes are imposed on him. All functions I implement in class followers. There are children in these classes In my window, I implement the table and in this table I have to write the children of different…
0
votes
0 answers

PyQt5 TableView kills kernal

So, Im currently taking just limited data from a ZeroMQ Messaging system appending it all to a Dataframe and then turning the Dataframe into a pandas model with code I acquired from someone on stack. Then running that model through a PyQt5…
0
votes
0 answers

How does QAbstractItemView know about my custom roles when emitting dataChanged() with no roles?

On receipt of the signal QAbstractItemModel::dataChanged(), the connected QAbstractItemViews will call the QAbstractItemModel::data() method to update their data. The user defined data() method should give different information based on both…
0
votes
1 answer

Unexpected padding pyqt in qtableview cell

I'm trying to create a custom TableModel class for QTableView. The cells containing 1 as data must have red outlining. Outlining is made by returning a pixmap (with red borders and text drawn on top) from TableModel instead of returning a simple…
0
votes
1 answer

Pyqt5 QAbstractTableModel dataChanged not updating data

I am trying to update my QTableView after I receive a notice via pydispatcher of a change in the system. I did create the following functions def rowCount(self, parent=None): return len(self.m_list) def columnCount(self, parent=None): …
PBareil
  • 157
  • 6
0
votes
1 answer

One Model, two different views - PySide

I have QAbstractTableModel with 4 columns. I'm trying to display the first 3 columns on a view (QTableView), and when a row is selected on such view a second view (a QListView) should display the 4th column of the model. I found something about a…
0
votes
2 answers

QTableView setSortingEnabled is forcing sortBycolumn

I am using a QTableView and when I enable sorting using the setSortingEnabled there is an immediate call to the sortByColumn(), but I do not want this as this sorts my table by default 1st column. I want just to enable sorting and not to force…
mapuna
  • 53
  • 1
  • 5
0
votes
1 answer

QML TableView from file

Good morning, I have some problems to create a tableview from file. Basically I just have a Button to load csv files and I want to show the files in a QML TableView... I think my main problem is that I have a dynamic number of columns. TableView { …
mBucks
  • 15
  • 5