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
74
votes
4 answers

How to make a column in QTableWidget read only?

I would like to have one column in QTableWidget NOT editable. In forums I have read a lot about some flags but could not manage to implement.
Narek
  • 38,779
  • 79
  • 233
  • 389
51
votes
13 answers

How to delete all rows from QTableWidget

I am trying to delete all rows from a QTableWidget . Here is what I tried. for ( int i = 0; i < mTestTable->rowCount(); ++i ) { mTestTable->removeRow(i); } I had two rows in my table. But this just deleted a single row. A reason could be that I…
vinayan
  • 1,597
  • 3
  • 19
  • 42
41
votes
2 answers

QTableWidget vs QTableView

I am new to this Model/View Framework of Qt. In my application I want to have 1000 X 1000 cells. There should be minimum memory requirement & it should be fast. I don't know what this Model terminology is for. But I have my own class which knows how…
Cool_Coder
  • 4,888
  • 16
  • 57
  • 99
33
votes
3 answers

How can I add a checkbox/radio button to QTableWidget

How can I add a checkbox/radiobutton/combobox to a QTableWidget or a QListWidget?
user664305
28
votes
5 answers

Resize column width to fit into the QTableWidget pyqt

I've googled around but I'm not able to find a solution to my problem. I have a QTableWidget with 2 columns and what I'm trying to do is to make them visible to the whole widget without the horizontal scrollbar to appear. With a picture it should be…
matteo
  • 4,683
  • 9
  • 41
  • 77
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
26
votes
6 answers

how to make a cell in a QTableWidget read only?

i have the following code defining the gui of my app class Ui (object): def setupUi(): self.tableName = QtGui.QTableWidget(self.layoutWidget_20) self.tableName.setObjectName(_fromUtf8("twHistoricoDisciplinas")) …
Rafael Rotelok
  • 1,102
  • 1
  • 14
  • 26
23
votes
3 answers

Set default alignment for cells in QTableWidget

I know you can set the alignment for each item using: TableWidget->item(0,0)->setTextAlignment(Qt::AlignLeft); However I would like to set a default alignment for all the cells in order to do not have to set it every time I create a new item. Is it…
jsalvador
  • 733
  • 2
  • 7
  • 18
17
votes
4 answers

How to add a row in a tableWidget PyQT?

I am currently working on a widget that was designed in Qt Designer. I am having trouble with the syntax / overall concept of trying to add a row to a Qtable in PyQT. There is no method, which I have yet found to dynamically add rows. Any…
sudobangbang
  • 1,406
  • 10
  • 32
  • 55
17
votes
4 answers

Selecting QComboBox in QTableWidget

One cell in each row of a QTableWidget contains a combobox for (each row in table ... ) { QComboBox* combo = new QComboBox(); table->setCellWidget(row,col,combo); combo->setCurrentIndex(node.type()); …
qtnewbie
16
votes
2 answers

How can I show data on QTableWidget and read data from it with header?

How can I show data on QTableWidget and read data from it with header?
ayla
  • 377
  • 4
  • 7
  • 14
15
votes
3 answers

How can I enable / disable QTableWidget's horizontal / vertical header?

If I set the horizontalHeaderVisible or verticalHeaderVisible attribute to false in Qt Designer, this works fine. But how can I enable / disable headers in my code? I've been trying something like this: self.ui.tblContents.horizontalHeaderVisible =…
eonhelm
  • 229
  • 1
  • 4
  • 8
15
votes
2 answers

Adding widgets to qtablewidget pyqt

Is there anyway to add like a button in qtablewidget? But the date within the cell would stil have to be displaying, for example if an user double clicked a cell, could i send a signal like a button? Thanks! edititem(): def editItem(self,clicked): …
user1582983
14
votes
4 answers

How to align the text to center of cells in a QTableWidget

I am using PyQt based on Qt4. My Editor is PyCharm 2017.3 and my python version is 3.4. I am scraping some text from a website. I am trying to align that text to the center of the cell in a QTableWidget. item =…
royatirek
  • 2,437
  • 2
  • 20
  • 34
13
votes
1 answer

how can I clear a pyqt QTableWidget?

I want to clear my QTableWidget. First of all I select a user in a qcombobox after that I click a qpushbutton and I populate it from database records; when I select other user and I click the qpushbutton to add data I try to clear…
GSandro_Strongs
  • 773
  • 3
  • 11
  • 24
1
2 3
79 80