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
14
votes
1 answer

QTableView column width

I'm struggling to set column width manually in a QTableView. Why doesn't this piece of code work? tabb = new QTableView; tabb->resizeColumnsToContents(); for (int col=0; col<20; col++) { tabb->setColumnWidth(col,80); } If I omit…
splunk
  • 6,435
  • 17
  • 58
  • 105
13
votes
9 answers

QTableView is extremely slow (even for only 3000 rows)

I have a table with 3000 rows and 8 columns. I use the QTableView. To insert items I do: QStandardItem* vSItem = new QStandardItem(); vSItem->setText("Blabla"); mModel->setItem(row, column, vSItem); where mModel is QStandardItemModel. Everything…
Tom
  • 171
  • 1
  • 1
  • 9
13
votes
1 answer

How to remove the vertical header in QStandardItemModel?

I have created a table using QTableView and a QStandardItem widget. How to remove the vertical header from QStandardItemModel?
Masthan
  • 727
  • 1
  • 8
  • 29
13
votes
2 answers

Set color to a QTableView row

void MyWindow::initializeModelBySQL(QSqlQueryModel *model,QTableView *table,QString sql){ model = new QSqlQueryModel(this); model->setQuery(sql); } With this method i can set a QSQlQueryModels to my QTableviews. But How i can set…
Tineo
  • 519
  • 1
  • 4
  • 19
12
votes
5 answers

What is the best way to display an animated icon in a QTableView?

I've been struggling with this for some times now, and I can't seem to find the right way to do this. What I would like is the ability to use an animated icon as a decoration for some of my items (typically to show that some processing is occuring…
Luc Touraille
  • 79,925
  • 15
  • 92
  • 137
12
votes
5 answers

How to delete row/rows from a qtableview in pyqt?

I am using QStandardItemModel for my qtableview. import ui_my_viewlogs import os from PyQt4 import QtCore, QtGui class my_viewlogs(QtGui.QDialog, ui_my_viewlogs.Ui_viewlogs): def __init__(self): super(my_viewlogs, self).__init__() …
Anuj Bhasin
  • 610
  • 1
  • 8
  • 18
12
votes
4 answers

QTableView - not allow user to edit cell

I created a QTableView with a QSqlTableModel. By standard, double-clicking on the cells will mark them and the user can edit them. I want, that the user isn't allowed to do that. He is allowed to mark the whole row by clicking on a single cell, but…
Berschi
  • 2,605
  • 8
  • 36
  • 51
12
votes
6 answers

Qt - How can I make a particular Column of my QTableView as Non Editable?

I have a QTableView with 4 Rows and 4 columns each representing their data's in it. By default the QTableView is editable. Now I want to make any particular column as non editable in my QTableView. How can I do it? Thanks in Advance.
New Moon
  • 787
  • 6
  • 21
  • 35
12
votes
1 answer

How can you edit a QTableView cell from a QTest unit test?

I'm writing a unit test for a custom Validator in a QTableView using the QTestLib framework. One of the most basic test cases could be described like this: Double click the table cell in the third column and the fourth row, and append the number…
Tim Meyer
  • 12,210
  • 8
  • 64
  • 97
11
votes
2 answers

How can I get right-click context menus for clicks in QTableView header?

The sample code below (heavily influenced from here) has a right-click context menu that will appear as the user clicks the cells in the table. Is it possible to have a different right-click context menu for right-clicks in the header of the table?…
c00kiemonster
  • 22,241
  • 34
  • 95
  • 133
11
votes
4 answers

How do I tell Qt to always show an editor in a QTableView?

I've got a QTableView for which I want to display the last column always in edit mode. (It's a QComboBox where the user should be able to always change the value.) I think I've seen the solution in the Qt documentation, but I can't find it anymore.…
Georg Schölly
  • 124,188
  • 49
  • 220
  • 267
11
votes
4 answers

Change QSortFilterProxyModel behaviour for multiple column filtering

We have a QSortFilterProxyModel installed on a QTableView and two (or more) QLineEdit for filtering the view (based on the text of these QLineEdits) In our view we have a slot that tells us the string of lineedits and the current column that we…
IMAN4K
  • 1,265
  • 3
  • 24
  • 42
11
votes
2 answers

Validating user input in a QTableView

I have a QTableView and I want to validate user input. If user insert an invalid value in a cell of the QTableView, I want to highlight that cell and disable a QPushButton. How can I achieve this? Can I use QValidator?
splunk
  • 6,435
  • 17
  • 58
  • 105
11
votes
1 answer

QTableView: how do I correctly create a QModelIndex?

I'm trying to enter edit mode on a specific cell like this: void MainWindow::on_addButton_released() { tm->addRow(); tableView->scrollToBottom(); int ec=tm->firstWritableColumn(); int r=tm->rowCount(QModelIndex()); QModelIndex id…
Chris Camacho
  • 1,164
  • 1
  • 9
  • 31
11
votes
3 answers

Qt Delete selected row in QTableView

I want to delete a selected row from the table when I click on the delete button. But I can't find anything regarding deleting rows in the Qt documentation. Any ideas?
laura
  • 2,085
  • 13
  • 36
  • 68
1 2
3
82 83