Questions tagged [qtablewidget]

QTableWidget is a Qt class providing an item-based table view with a default model.

Table widgets provide standard table display facilities for applications. The items in a QTableWidget are provided by QTableWidgetItem.

If you need to use your own data model, then QTableView is preferrable.

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

1192 questions
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

QTableWidget - Change the row color

I'm trying to change the background color of a QTableWidget row. There are some others posts about the same thing but none of the given solutions worked for me. With that solution, we are setting the background on an already existing item in the…
stepBystep
  • 187
  • 1
  • 1
  • 8
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
12
votes
2 answers

How to make QTableWidget's columns assume the maximum space?

The columns of my QTableWidget do not fill in the space of the table, so that an empty space is left on the right hand-side. How to make the columns of my QTableWidget assume the maximum space so as to fill in this space?
neydroydrec
  • 6,973
  • 9
  • 57
  • 89
11
votes
1 answer

How to prevent user from resizing columns of QTableWidget?

I'd like to manage width of my columns in a table personally, but after resizing them from the code, I cannot figure out a way to prevent user from resizing them manually. I found out that QTableView has the columnResized() slot, and the only ways…
Septagram
  • 9,425
  • 13
  • 50
  • 81
11
votes
4 answers

How to disable selection highlighting in a QTableWidget?

I have a QTableWidget with a disabled setSelectionMode (QTableWidget::NoSelection) and the QTableWidgetItems I fill in don't have the Qt::ItemIsEditable flag. Nevertheless, a cell that has been clicked gets some kind of cursor (the black line at the…
Tobias Leupold
  • 1,512
  • 1
  • 16
  • 41
11
votes
3 answers

Turn off PyQt Event Loop While Editing Table

I'm developing a GUI with PyQt. The GUI has a qListWidget, a qTableWidget, and a plot implemented with Mayavi. The list refers to shapes that are plotted (cylinders and cones for example). When a shape is selected in the list, I want the shape's…
flutefreak7
  • 2,321
  • 5
  • 29
  • 39
10
votes
2 answers

PyQt:How do i set different header sizes for individual headers?

I have a list containing lists with two items,a word and a number.This list will be presented using a tablewidget. My aim is to produce a table with two columns and with the neccessary rows,but the header of the column which will have the words…
IordanouGiannis
  • 4,149
  • 16
  • 65
  • 99
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
10
votes
1 answer

Can we make QTableWidget to smooth scroll its content?

I have a QTableWidget displayed rows with different height. It cause the scrolling behaviour looks jumpy. I think even if all the rows were in the same height, the scrolling is also not smooth. Haven't found an answer to this issue (or maybe it was…
swdev
  • 4,997
  • 8
  • 64
  • 106
10
votes
1 answer

PyQt: QTableWidget to .xls file

So, I have a QTableWidget that I want to save it to an .xls file using the xlwt module... Here's the code: def savefile(self): filename = unicode(QtGui.QFileDialog.getSaveFileName(self, 'Save File', '', ".xls(*.xls)")) wbk =…
Antoni4040
  • 2,297
  • 11
  • 44
  • 56
9
votes
1 answer

Python - PyQt - QTable Widget - adding rows

i am new to PyQt and still bit confused anyhow. I have a text file structure like this: Name Surname Telephone Email Where spaces are actually tabs " \t " now when i read this file whit my method i wish to populate the QTable Widget. My…
Sterling Duchess
  • 1,970
  • 16
  • 51
  • 91
9
votes
5 answers

python qt : automatically resizing main window to fit content

I have a main window which contains a main widget, to which a vertical layout is set. To the layout is added a QTableWidget only (for the moment). When I start the application and call show on the main_window, only part of the QTableWidget is shown.…
Vince
  • 3,979
  • 10
  • 41
  • 69
9
votes
3 answers

Set widget background color

I use QCheckBox in QTableWidgetCell QWidget *widget = new QWidget(); QCheckBox *checkBox = new QCheckBox(); QHBoxLayout *layout = new…
Ufx
  • 2,595
  • 12
  • 44
  • 83
1
2
3
79 80