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

How to catch key presses in editable QTableWidgetItem?

Now I can process all key presses in my QTableWidget in a function eventFilter() (after calling of myTable->viewport()->installEventFilter(this); in the constructor). The only place where this doesn't work is editable cell while editing (because it…
Ilya
  • 4,583
  • 4
  • 26
  • 51
5
votes
3 answers

Qt - Cannot put an image in a table

Why with the following code I just get an empty table widget? QString imgPath = "C:\\path\\to\\image.jpg"; QImage *img = new QImage(imgPath); QTableWidget *thumbnailsWidget = new QTableWidget; QTableWidgetItem *thumbnail = new…
Pietro
  • 12,086
  • 26
  • 100
  • 193
5
votes
2 answers

add custom widget to QTableWidget cell

I have custom widget made with qt designer and i want to add it to QTableWidget cell. But it doesn't work. Here is the code : int nRows =10; for(int row = 0; row < nRows;row++;) { QTableWidgetItem* item = new QTableWidgetItem(); CustomWdg*…
user152508
  • 3,053
  • 8
  • 38
  • 58
5
votes
2 answers

The first time a QTableWidget is populated, everything is fine, but when i repopulate it, it's significantly slower

THE CODE: populateTable() { tableWidget->clearContents(); tableWidget->setRowCount(stringList.size()); for(int i = 0; i < stringList.size(); ++i) { tableWidget->setItem(i, 0, new QTableWidgetItem(stringList.at(i))); } } THE…
Subaru Tashiro
  • 2,166
  • 1
  • 14
  • 29
4
votes
1 answer

How to make table view corner items corners round?

I have a QTableWidget (alternatively, a QListWidget) which I want to style in the following way: The "selected" color of the cells should be a certain fixed color. I am able to do this by using the following stylesheet: QTableWidget::item:selected…
Borage
  • 43
  • 3
4
votes
2 answers

How do I assign a border to a specific QTableWidgetItem or a row in a QTableWidget?

I am trying to make certain cells in my QTableWidget have different colored borders based on the information contained in an item(cell). I do not want to select those cells and use the selection-color styles because different cells need to be…
Brian
  • 41
  • 1
  • 2
4
votes
1 answer

QTableWidgetItem set hidden data

Given a QTableWidget, is there a way to set an "hidden" value for a cell (QTableWidgetItem), different from the displayed value? For example, my cell should show "Item 1" text, but double clicking on it the editing should be only on the value 1,…
ABCplus
  • 3,981
  • 3
  • 27
  • 43
3
votes
2 answers

How to prevent too aggressive text elide in QTableview?

I have an issue with text elide in Qt being too aggressive in a table, see picture. The cell with the full figure 0.8888.... I've edited since the QTableWidget was shown, the others are are as the were when the QTableWidget was created. It seems…
user2052153
  • 129
  • 10
3
votes
2 answers

Create a QTableWidgetItem with flags()

I dont understand the Qt5 Documentation in the TableWidgetItem-Chapter. I cant get the right parameters to set my freshly created TableCell as editable. I've got this piece of code for i, item in enumerate(event_desc, start=0): …
Heini
  • 295
  • 2
  • 10
3
votes
0 answers

Place Image in PyQt QTableWidget Header

I am trying to create a QTableWidget that has a thumbnail image in it's vertical header (and eventually some text under it). My current attempt is to subclass the QTableWidgetItem... class ShotHeader(qt.QTableWidgetItem): imagePath =…
3
votes
1 answer

how to get the selected combobox value from QTableWidget?

I have created a QTableWidget in which for a column I am setting a combobox QComboBox using setCellWidget function. It works fine . This is how i set up the qtablewidget cb = QComboBox() cb.addItems(["Java", "C#",…
Abhijit Gujar
  • 433
  • 6
  • 15
3
votes
2 answers

QT Inherit from QTableWidgetItem to Widget and overide '<' operator

I want a QTableWidget with certain cells as customized QProgressBars, and I want it to be possible to sort the columns containing these. My customized QProgressBar is inheriting from both QProgressBar and QTableWidgetItem, and I am overiding the '<'…
remi
  • 937
  • 3
  • 18
  • 45
3
votes
2 answers

PyQt QTableWidget setItem loop

I've been able to use QTableWidget and QTableWidgetItem to populate info from our database into a QTableWidget based on the text returned in the search bar. While I'm able to get the searched item to populate all the info into a tablewidget, I am…
Notmeomg
  • 31
  • 1
  • 1
  • 2
3
votes
0 answers

align each column differently in QTableWidget

I need to create a table like this how can I align first column left, 2nd and 3rd columns center, and last column right sothat when someone put data in, it is automatically aligned as I want ? My first…
trangan
  • 341
  • 8
  • 22
3
votes
2 answers

How to set cell border and background color in QTableWidgetItem?

I have a QTableWidget with 3 columns. 2 of the columns have some text in them, but one of them is empty and I want it to have a background color. Also I want the cells to have borders. If I do int i = 0; foreach (tableData el, data) { //setting…
N Alex
  • 1,014
  • 2
  • 18
  • 29
1
2
3
14 15