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

QAbstractTableModel emits dataChanged, but update is never drawn

I am using Python and the PySide2 Qt bindings. My program is intended to load records from a csv file, display them as rows in a table, and when asked, upload each to a remote database. Each upload takes a few seconds, so I figured I'd change the…
aurath
  • 1,347
  • 3
  • 13
  • 19
1
vote
1 answer

QAbstractTabelModel.data() always getting index.row() == 0 and only shows 1 row

I have defined my custom QAbstrtactTableModel in python and implemented columnCount(), rowCount(), data() and headerData() and also added a function to add() new entries: import sys from PySide2.QtUiTools import QUiLoader from PySide2.QtWidgets…
bardao
  • 914
  • 12
  • 23
1
vote
1 answer

How to update data in QAbstractTableModel with different row count

I am developing an application that updates the data in QTableView from apache server once per second. The server sends data as XML table. Number of columns is constant, but the number of rows changes each time. The data in the rows may also…
1
vote
0 answers

How to set the model's column index of a TableViewColumn in QML using QAbstractTableModel

This question is basically asking the same thing - Is it possible to use QAbstractTableModel with TableView from QtQuick.Controls? I have a QAbstractTableModel with data in the rows and columns. I want to be able to specify which column in my model…
mx5_craig
  • 108
  • 10
1
vote
1 answer

qtableview add and display ordered items as they arrive arbitrary?

I want to display a set of ordered items 1:N according to their ordering, as they arrive arbitrary, for example suppose the following items arrived in the following order: #1,#2,#10 then the Qtableview should display them in the correct order…
sam
  • 11
  • 1
1
vote
1 answer

How to access another index inside paint() function of delegate?

When mouse is over a cell of a table, I need to create an effect for the whole row of that cell. That means I need to access to another index. In this case I made a for loop, run from the first column to last column of the table and set effect for…
trangan
  • 341
  • 8
  • 22
1
vote
1 answer

PyQt QAbstractTableModel checkbox not checkable

I am using own table model with QAbstractTableModel, where I have first col with checkbox (checkable cause flags Qt.ItemIsUserCheckable | Qt.ItemIsSelectable | Qt.ItemIsEnabled). I have trouble when I am trying use checkboxes, cause they are not…
Dave
  • 87
  • 9
1
vote
0 answers

QTableView displaying a subset of rows in a random order

I'm looking for a way to have a QTableView show a subset of the total rows in the QAbstractTableModel in a random order. I have found QSortFilterProxyModel to display a subset of rows (filter). However, it can't do a random order, it can only do…
Jeroen3
  • 919
  • 5
  • 20
1
vote
0 answers

Requesting model data from network

When in model methods rowCount() and columnCount() I try to retrieve data from server using QTcpSocket, the model calls these methods few times but not calls data() afterwards. The associated QTableView displays nothing. I checked with debugger and…
1
vote
1 answer

Is it possible to use Factory Girl to update an already instanced factory?

I am trying to streamline our cukes trying to leverage the wonderful factories built into our system for unit tests. I am setting up a @bread ||= FactoryGirl.create(:bread) in a background step. Throughout that feature, I want to add a trait which…
Vinchbr
  • 49
  • 4
1
vote
2 answers

AbstactTableModels that work on the same data source

Let's say i want to implement a library tool to manage different types of media. Therefore i have a base class Medium and derived classes e.g. Book and DVD which have additional properties. My Problem is i can't figure out how to design the models…
trixn
  • 15,761
  • 2
  • 38
  • 55
1
vote
1 answer

How to query open persistent delegate item

Clicking the tableView's item opens a PersistentEditor: it defaults to QSpinBox for the first column (since integer data) and QLineEdit for two others. onClick I would like to query how many persistent editors have been already opened for the…
alphanumeric
  • 17,967
  • 64
  • 244
  • 392
1
vote
1 answer

How to get delegate item when QTableView is clicked

The code below creates the single QTableView. There is a QItemDelegate is assigned as a PersistentEditor. There are two kind of editors created: QLineEdit is created for the column 0 and the 'QComboBox` is created for the column 1. When the…
alphanumeric
  • 17,967
  • 64
  • 244
  • 392
1
vote
1 answer

QAbstractTableModel and Unicode (german umlauts)

I have a Unicode problem. The German Letters ä, ü, ö and ß are only visible as a white question mark in a black rhombus. I've made a QAbstractTableModel in Qt5.5.1. My document is UTF-8 coded. I already tried this, but I still get the same…
1
vote
1 answer

Qt: undefined reference on constructor of customer class

I'm using a custom class, GpibDevicesModel, inheriting from QAbstractTableModel, and the compiler says that there is an undefined reference on the constructor. But I don't understand why. Here is the code: MainWindow.h class MainWindow : public…
Gojir4
  • 313
  • 2
  • 17