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

Adding row to QTableView with model and and delegate widgets

I am trying to add a row to QTableView with a QAbstractTableModel and QItemDelegate where the widgets appear in the added row. From what I've read I need to call .edit(index) on each item of the added row to call createEditor where the widgets are…
Zoes
  • 29
  • 4
0
votes
1 answer

How to insert a new column to a QAbstractTable Model at runtime using PYQT

I have created a model class of type QAbstractTableModel to which I have added a number of methods as shown here: class resultsModel(QAbstractTableModel): def __init__(self, parent, headerData, arraydata, *args): …
Ben
  • 765
  • 1
  • 5
  • 9
0
votes
0 answers

Creating a QTreeView from a given list using pyqt

I want to create a TreeTable with a given data from a list of lists. At the moment I only managed to create a normal table with the help of a QTableView and a QAbstractTableModel. Now I want to convert this into a tree. The tree should look…
enyo
  • 41
  • 4
0
votes
1 answer

Qt C++ QabstractTableModel set checkbox column to unchecked initially

I'm having trouble with correctly implementing a column of checkboxes on a class that inherits from QAbstractTableModel. Each row in the table has a checkbox that's initially checked when a new item comes in, which I need to be unchecked. I've tried…
sean1441
  • 9
  • 2
0
votes
0 answers

Set 'role' in QAbstractTableModel

I was trying to build a simple QAbstractTableModel to familiarize myself with the concepts. The model I build however, is not behaving as I anticipated. I would like the model to display a tick mark whenever the value 'status' in a cell is True. The…
Max
  • 3
  • 1
0
votes
0 answers

Displaying Image in QTableview PyQT

I am trying to make a file browser imitation in PyQt5. Files to be displayed in one horizontal row (similar to adobe lightroom). Used Qtreeview with two rows, 1 for filename to be displayed another for a thumbnail and QAbstractTableModel. Managed to…
0
votes
1 answer

how to diseable select row behavior when adding/deleating a row in QTableView

I have a subclassed QAbstractTableModel with a insert/deleate rows method in the main window I have a methods insert_data thats insert a string when the cell is currently selected (I turned on singe selection) Here is the behavior that I want to…
Sator
  • 636
  • 4
  • 13
  • 34
0
votes
2 answers

How can i align (center) row data in Python PyQt5 QTableView?

I want to align my all rows in model. I compile .ui to .py in 'QtDesigner' and creates form.py. Ui_MainWindow comes from form.py . Can you explain the solve with examples? Re:I want to align my all rows in model. I compile .ui to .py in 'QtDesigner'…
0
votes
1 answer

How to align one number to the left and one to the right in the same cell? Also make them different colour

I have a QAbstractTableModel and I want to draw one number aligned to the left and one to the right in the same cell like this: ╔══════════════════════╦═════╗ ║ 31 +15 ║ foo ║ ║══════════════════════╦═════║ ║ 11 +15 ║ xxx…
user9536240
0
votes
2 answers

Access original index in QAbstractTableModel from selected row in QTableView

I am implementing a GUI for a python programme using Qt5 and PySide2. I have no problem understanding the C++ side of Qt, so feel free to point out Qt references not related with python. I have some data that I display in a QTableView using a…
Arthur
  • 115
  • 9
0
votes
0 answers

removeRow in QTableView/QAbstractTableModel by CheckBox

I've created a table view where I'm trying to drop rows by clicking the checkbox embedded in the table view. I get to the point where it indexes the correct row when the checkbox is deselected, but the model refuse to remove the row and instead…
0
votes
2 answers

How to send QSqlQueryModel over QTcpSocket with QDatastream?

I want to send QSqlQueryModel to the another client with QDatastream and QTcpSocket. I want to remove some rows and add few extra rows to QSqlQueryModel (without changing the database) and send it to the client like this pseudocode:- QTcpSocket…
LightSith
  • 795
  • 12
  • 27
0
votes
1 answer

How to add QTableView inside a QGroupBox

I'm looking for help regarding how to add a QTableView inside a QGroupBox (this is because i need to create 4 QTableView each displaying one of each possible Status 'In QC','Ready for QC','In Progress','Pending'). The following code currently…
Magthuzad
  • 160
  • 1
  • 1
  • 10
0
votes
1 answer

Is there a QML grid-like control that I can attach to a QAbstractTableModel, I'm keen to use columns in the model, not roles

I want to write some QML to edit a CSV file, presenting a grid-like array of textboxes to allow user input/output. I plan to write a C++ subclass of QAbstractTableModel to represent the file, I can foresee no problems with doing so. My subclass will…
0
votes
1 answer

Optimize PyQt5 QAbstractView for Pandas Model

I am currently writing a SQL query interface through Python. When writing the data into a QTableView, I am using a QAbstractTableModel to write the query result. This works fine for smaller queries, but becomes extremely slow when trying to present…
Drew M.
  • 49
  • 6