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

QTableWidget Drag/Drop rows does not change their location when accessing by index

I have a QTableWidget, that allows moving of rows by dragging and dropping. The initial table looks as follows: If clicking on the button, it prints all the values as they are in the table. Now after dragging row 2 to the the position of row 4,…
2
votes
0 answers

How do I update SQL database from QTablewidget using only the cells which have been changed

I am populating a QTableWidget from a sql database and would like to specifically update the values which have been added to the database via the tablewidget instead of over-writing the entire database with the table widget data. Like assuming the…
E. Artemis
  • 69
  • 1
  • 8
2
votes
1 answer

How to iterate a column in QTableWidget and check if a check box is checked?

How can I iterate one column in QTableWidget and check if a checkbox is checked? When I clicked the button in the left, I want to iterate the column in the picture and check if a checkbox is checked. As of now, I've tried this function but the…
Eliazar
  • 301
  • 3
  • 13
2
votes
1 answer

How to select an item in a QTableWidget using pytest-qt mouse click?

I have a table in my main GUI. I want to test my ability to delete items in the table using a menu that comes up upon right-clicking on an item. I'm using pytest-qt to conduct testing. Using qtbot.mouseClick seems to work well when clicking on…
2
votes
1 answer

how to have auto-completer in a QTableWidget cell that newly-created in pyqt5?

I am trying to have auto-completer in my table cells and it is working but the problem comes when I add a new row to the table, 1. how can I add the same functionality to newly-created rows? I use _addRow method to add a new row. 2. how can I add…
Dariyoush
  • 500
  • 4
  • 16
2
votes
1 answer

How to catch left and right mouse click event on QTableWidget in PyQt5?

I have created a QTableWidget using PyQt5 and openpyxl to load excel in VSCode and I am having trouble to catch/get the left and right mouse click buttons separately. Left click to copy the cell content to the clipboard and Right click to cell to…
Geni-sama
  • 307
  • 5
  • 15
2
votes
1 answer

pyqt5 qtablewidget cell background while editing cell

self.grid.setStyleSheet("QTableWidget::item::selected { background-color:#F9F6F5 ; color:black; border: 3px solid black; }") currently i'm using styleSheet for my qtablewidget background when i select an item it changes that cell's…
FurkanOzcelik
  • 75
  • 1
  • 7
2
votes
1 answer

Incomplete population of QTableWidget after sorting

I have a QTableWidget which will be populated with some random values. The table has sorting enabled: tableWidget.setSortingEnabled(True). Sorting works fine (I know, in this minimal example it will be alphanumerical sort of numbers). However, when…
theozh
  • 22,244
  • 5
  • 28
  • 72
2
votes
1 answer

How to get the cursor position in a cell of QTableWidget

I have a QTableWidget and I need to know the position of the cursor in a cell. For QLineEdit there exists a function QLineEdit::cursorPosition( ). Is there something similar for a cell in a QTableWidget or for a QTableWidgetItem? Or any other method…
Quizard
  • 71
  • 1
  • 5
2
votes
2 answers

Missing column headers in saved file

Is it possible I get assistance here? My function saves a file with a space after every row, also the column headers are not saved. Here is the function. def download_results(self): try: path = QFileDialog.getSaveFileName(MainWindow,…
Ptar
  • 168
  • 8
2
votes
1 answer

Select a text in PYQT to copy

I designed a windows desktop app with QT Designer and PYQT5. The problem is that, I can not select any item, text on main window, or on qtablewidget to paste it manually somewhere else. It will make things easier for users not for me. ` from PyQt5…
2
votes
1 answer

How to completely disable selection for qtableview (for all cells)?

I want my table to be not selectable, so that only check boxes or radio buttons could be selected, but not the cell itself. Now I have: How can I fix this? Solutions for QTableWidget can help too.
2
votes
1 answer

Pick values by dragging in PyQt5 and store it in a list

I'm making an app using PyQt5 that I can pick values by dragging from 1 position to another position like this image: All the values were picked will be stored in a list like: [['4.9', '3.0', '1.4', '0.2'], ['4.7', '3.0', '1.4', '0.2'], ....…
Jiro Akira
  • 91
  • 5
2
votes
2 answers

How to make particular cell editable and leave the rest non-editable in QTableWidget?

I have QTableWidget which is non editable.(i had setup noEditTriggers while creating Ui file). I want to make particular cell editable from each row. how i can get this done? I looked into several answers on SO and other platforms but didn't get…
Vi_py123
  • 73
  • 1
  • 9
2
votes
1 answer

How to sort a QTableWidget by column by clicking on the header of the column?

I am building a database for my work. I want to be able to sort the elements in a manner similar to how you can sort elements in excel by clicking the header of a column. I am using the pandas library so I plan on sorting with that, but my main…
Chris Ray
  • 41
  • 1
  • 3