Questions tagged [qtableview]

QTableView is a Qt class providing a default model/view implementation of a table view.

A QTableView implements a table view that displays items from a model. This class is used to provide standard tables that were previously provided by the QTable class, but using the more flexible approach provided by Qt's model/view architecture.

QTableView implements the interfaces defined by the QAbstractItemView class to allow it to display data provided by models derived from the QAbstractItemModel class.

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

1244 questions
6
votes
1 answer

PyQt5 : how to Sort a QTableView when you click on the headers of a QHeaderView?

I want to sort a QTableView when I click on the headers of my QHeaderView. I've found a several code sample on the internet like this one: Sort QTableView in pyqt5 but it doesn't work for me. I also look in the Rapid Gui programming Book from…
BillyBoom
  • 191
  • 2
  • 14
6
votes
1 answer

PyQt - Load SQL in QAbstractTableModel (QTableView) using pandas DataFrame - editing datas in a GUI

I'm quite new to python and using WinPython-32bit-2.7.10.3 (including QTDesigner 4.8.7). I'm trying to program an interface for using a sqlite database on two separates projects, using QtableViews. The algorithm is roughly so : - connect to database…
tgrandje
  • 2,332
  • 11
  • 33
6
votes
1 answer

Why do I not see the drop indicator in a QTableView?

I use drag and drop in my QTableView (works). However, I do not see any drop indicator. I should see a line where the drop is supposed to be inserted, shouldn't I? At least here they say so. My init is pretty much standard. // see model for…
Horst Walter
  • 13,663
  • 32
  • 126
  • 228
6
votes
1 answer

HowTo make restoreState() and saveState() work correctlly to QTableView class?

First of all, I wanted to say, that my problem was already discuss here, on SO, and here it is. But the answers are not the good ones... So, here is the problem: I have a QTableView class, with a simple model, connected with…
mosg
  • 12,041
  • 12
  • 65
  • 87
6
votes
1 answer

Add items to columns in QStandardItemModel

I am currently adding rows to my QTableView as such QStandardItem* itm; QStandardItemModel* model = new QStandardItemModel(this); model->setColumnCount(2); model->appendRow(new QStandardItem("Some Text in Column1"); How do I add items to column 2…
James Franco
  • 4,516
  • 10
  • 38
  • 80
6
votes
2 answers

QTableView sorting signal?

I use QTableView + QStandardItemModel to show some data (data stored in some other data structure), and this table view is sortable. Since it is sortable, when sorting this model, I also need to sort the order of stored data. I try to implement a…
Claire Huang
  • 961
  • 1
  • 18
  • 30
6
votes
1 answer

How to prevent QTableView item from getting cleared on double-click

With QTableView set as editable using QAbstractTableModel's flag() method: def flags(self, index): return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsEditable double-clicking the QTableView's item puts this item into the editing mode. By…
alphanumeric
  • 17,967
  • 64
  • 244
  • 392
6
votes
1 answer

changing the default row size in a QTableView

How do you change the default row size in a QTableView so it is smaller? I can call resizeRowsToContents(), but then subsequent inserts still add new rows at the end which are the default size. I am guessing it might have something to do with style…
Jason S
  • 184,598
  • 164
  • 608
  • 970
6
votes
1 answer

How to sort a QTableWidget with my own code?

I am using Qt4.5.2 on Linux. I have a simple QTableWidget, in which a column displays dates in a human-friendly format. Unfortunately "human-friendly dates" are not easy to sort correctly. So, in the QTableWidget I keep a hidden column with the UNIX…
laramichaels
  • 1,515
  • 5
  • 18
  • 30
6
votes
2 answers

QTableView Zoom In/Out

I'm trying to create a QTableView that can be zoomed in and out like in Excel. A similar question was asked here: Zooming function on a QWidget However, I'm subclassing the QTableView in PyQt and not C so reimplementing the entire PaintEvent method…
TexasRaptor
  • 105
  • 5
6
votes
2 answers

Show other data in QTableView with QItemDelegate

I have a QTableView connected with an QSqlTableModel. In the first column, there are only dates at this format: 2010-01-02 I want this column to show the date at this format (but without changing the real data): 02.01.2010 I know that I have to…
Berschi
  • 2,605
  • 8
  • 36
  • 51
6
votes
2 answers

Is there any way to save the order of columns?

I currently have a tableview attached to a class that is derived from QSortFilterProxyModel. Now I wanted to know if there is any way by which I can store the order of columns since the users tend to move the columns back and forth. Also is there…
Rajeshwar
  • 11,179
  • 26
  • 86
  • 158
6
votes
2 answers

What's the "editing finished" signal of a QTableView item?

I want to know when user has finished editing a QTableView item, so I checked all the available signals, but I only found ones that will emit before the edit. So, what should I do now? Running Qt 4.8.4
daisy
  • 22,498
  • 29
  • 129
  • 265
6
votes
2 answers

How to change background color after editing QTableView cell?

i have this QTableView with custom model and delegate, how do i change the background color of the cell after editing it? shall i do this in delegate's setModelData() ? index.model.setData(index, QVariant(True),Qt.UserRole) and later in model's…
Shuman
  • 3,914
  • 8
  • 42
  • 65
6
votes
3 answers

Qt - how to save my QTableView as a Excel File?

Can anyone plz help me, how to save my QtableView as a Excel File. I have a QTableView and a QPushButton (Save Button). If i enter the values in my QtableView and if i click the Save Buttton the QTableView items should be saved as Excel File. Plz…
New Moon
  • 787
  • 6
  • 21
  • 35