Questions tagged [qtablewidgetitem]

QTableWidgetItem is a Qt class providing an item for use with the QTableWidget class.

Table items are used to hold pieces of information for table widgets. Items usually contain text, icons, or checkboxes.

The QTableWidgetItem class is a convenience class that replaces the QTableItem class in Qt 3. It provides an item for use with the QTableWidget class.

Top-level items are constructed without a parent then inserted at the position specified by a pair of row and column numbers:

QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg(pow(row, column+1)));
tableWidget->setItem(row, column, newItem);
212 questions
28
votes
1 answer

How change the background color for a blank cell in QTableWidget

If a cell have some data, using tableWidget->item(8,0)->setBackgroundColor(Qt::red); to change the background color will work, but if a cell is blank it will fail.
spy8888
  • 315
  • 1
  • 5
  • 9
24
votes
2 answers

how to add a right click menu to each cell of QTableView in PyQt

I want to add a right click menu to delete, rename or open image in each of cell of QTAbleView in the rigt click menu, I have tried and found everyone is trying to add menu to a header in tableview, i tried below but that seems not working in the…
Ciasto piekarz
  • 7,853
  • 18
  • 101
  • 197
14
votes
8 answers

Qt - Centering a checkbox in a QTable

In QtCreater I added a table to my project. in my code I am generating some data to output into the table. I want to add a QCheckbox into each row to allow the row to be selected. All the content of the table is aligned left, how do I make only…
Mitch
  • 519
  • 2
  • 7
  • 16
13
votes
1 answer

Resizing QTableWidget Columns and Rows to Fill Table

I have a QTableWidget with an N number of columns, which when the number of columns are set, they automically fill in the entire QTableWidget. When I try to dynamically change the number of columns to N/2 columns, the size of each column does not…
sj755
  • 3,944
  • 14
  • 59
  • 79
12
votes
1 answer

Add a QPushButton into a QTableWidgetItem in a QTableWidget, How to make it Qt::AlignHCenter

for(int i=0; i(*it); ui.table->setItem(i,0,new QTableWidgetItem(user.userName)); ui.table->setItem(i,1,new QTableWidgetItem(user.sex)); ui.table->setItem(i,2,new…
zack chen
  • 137
  • 1
  • 1
  • 10
12
votes
2 answers

How to change Qtablewidget's specific cells background color in pyqt

I am new in pyqt4 and I can't figure out how to do this. I have a QtableWidget with data in it. I want to change some background color of the tableWidget's cells. I tried self.tableWidget.item(3, 5).setBackground(QtGui.QColor(100,100,150)) and it…
alperyazir
  • 203
  • 1
  • 4
  • 14
10
votes
3 answers

Adding images to a QTableWidget in PyQt

I'm very new to Python and even newer to PyQt. I've managed to create a table, but want to add images in certain cells. I've read that I need to subclass the QTableWidget class, or possibly the QTableWidgetItem class and re-implement the…
Stephen
  • 663
  • 5
  • 13
  • 24
9
votes
2 answers

Qt - How to associate data with QTableWidgetItem?

I want to associate additional data with each QTableWidgetItem inserted into the table, in order to use that data in future, when it is being clicked on a table item. But that data should not be visible. How can I do that?
Narek
  • 38,779
  • 79
  • 233
  • 389
9
votes
4 answers

QTableWidget memory leak or not?

Suppose I have a 2D array full of data say 10 x 10. The contents, as well as a number of rows, can change any time. Now I want to display this data in a QTableWidget. I use a timer with time out 1sec to refresh the table contents. In the timeout…
Anjanu
  • 623
  • 2
  • 8
  • 19
8
votes
2 answers

Show image in a column of QTableView from QSqlTableModel

I'm curious about how I can display an image from my database in a QTableView. Is there something like QTableWidgetItem that I am able to use it in QTableView? I use QSqlTableModel.
dare
  • 662
  • 1
  • 6
  • 15
8
votes
4 answers

How to use a validator with QTableWidgetItem?

Assuming I have a QTableWidgetItem item and I just wanna validate data that users enter. Example, users only enter a number into that item otherwise the program will show a warning dialog. I also search on that document page but I didn’t find…
Tan Viet
  • 1,983
  • 6
  • 25
  • 36
6
votes
2 answers

QTableWidget, centering cellWidgets

Is there a way to place QCheckBox as a cell widget of QTableWidget in the center of a cell, not at the left side, without additional QWidget and adding the checkbox to it's layout?
6
votes
1 answer

QTableWidget Integer

I am trying to insert and display integers in my QTableWidget. They don't display. It works if I convert everything to strings, but then I can't sort columns numerically--only lexically (1, 10, 100, etc.). This is using PyQt. I've tried some of…
Paul Nelson
  • 1,291
  • 4
  • 13
  • 20
5
votes
2 answers

How to show the row where QPushButton is clicked in QTableWidget

I would like to delete row where QPushButton is clicked how it is possible to I think it is reasonable to use slots but how to do it don't know , if you have any ideas how to get a row of selected button please share, thanks. It is my table It is a…
user8167852
5
votes
2 answers

Detect click and get text of QTableWidget header, how?

I see how to detect click in a QTableWidget cell by watching the cellClicked(int row, int column) signal (code below). I would like to do the same for the cells of the horizontal header and get the text of the clicked header cell. How do I do…
KcFnMi
  • 5,516
  • 10
  • 62
  • 136
1
2 3
14 15