Questions tagged [qstyleditemdelegate]

The QStyledItemDelegate class, part of the Qt framework, provides display and editing facilities for data items from a model.

When displaying data from models in Qt item views, e.g., a QTableView, the individual items are drawn by a delegate. Also, when an item is edited, it provides an editor widget, which is placed on top of the item view while editing takes place. QStyledItemDelegate is the default delegate for all Qt item views, and is installed upon them when they are created.

The QStyledItemDelegate class is one of the Model/View Classes and is part of Qt's model/view framework. The delegate allows the display and editing of items to be developed independently from the model and view.

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

143 questions
3
votes
0 answers

How to make QTreeView recalculate row heights?

There are QTreeView with subclassed QAbstractItemModel and custom QStyledItemDelegate. Custom delegate's sizeHint reimplemented and returns calculated correct cell height, considering text wrapping. So the problem is that cell's height is not…
Rinat
  • 1,941
  • 2
  • 17
  • 26
3
votes
2 answers

QListView with CustomWIdget using QStyledItemDelegate

I'm trying to create a QListView with QStyledItemDelegate to show data more organizing way. I gone through this site, and its all in C++, and I have no idea about it, guessing from the syntax and calls which has been used in the post, I tried my way…
Mahendra
  • 335
  • 1
  • 5
  • 12
3
votes
1 answer

What is the parent of createEditor in a QStyledItemDelegate (PySide/PyQt/Qt)?

I have a QTreeView of a QStandardItemModel. I am painting/editing the data using a custom delegate. Within createEditor method, I use parent.window() to access the main window of the entire application (see below to link to some code from another…
eric
  • 7,142
  • 12
  • 72
  • 138
3
votes
1 answer

Drawing line render issue in a QTableWidgetItem

I would like to draw a line inside QTableWidgetItem. To draw the line I have reimplemented the QStyledItemDelegate::paint method. But, when I'm scrolling or selecting an item in the QTableWidget. Some of the items loose their drawing effect. Here's…
Simon
  • 1,522
  • 2
  • 12
  • 24
3
votes
3 answers

Painting QPixmap in the center of QTableView cell

I have a QTableView that works very well, the first column holds some thumbnails, in each cell of this column the thumbnails are vertically centered, but not horizontally centered. Do I really need to use a delegate? If yes, How to center them…
Mohamed Anwer
  • 172
  • 2
  • 15
3
votes
1 answer

dataChanged signal does not work with ComboBoxDelegate

My problem is the following: There is a QTableViewand a QStandardItemModel used in this way: ui->tableView->setModel(model); model->setItem(myrow, mycolumn, myQStandardItem); and a comboboxdelegate: ComboBoxDelegate* mydelegate = new…
3
votes
1 answer

Setting background for row in PySide QTreeWidget

I started with the answer from a previous post but it doesn't seem to be working. All the rows render the same color. I create a main window class import sys from PySide import QtCore, QtGui class MainWindow(QtGui.QMainWindow): def…
devanl
  • 1,232
  • 1
  • 10
  • 20
3
votes
2 answers

HowTo draw different backgrounds with QStyledItemDelegate?

Problem: I have QTreeView object, and a QStandardItemModel as model to view widget; For some item's I have set data with setData method to split them with a parameter; So I need to draw different background pixmap for QStandardItem items, which are…
mosg
  • 12,041
  • 12
  • 65
  • 87
2
votes
1 answer

How to paint an outline when hovering over a QListWidget item?

I am trying to paint an outline around a QListWidget item when the mouse is over that item. I've subclassed QStyledItemDelegate and overrode paint to account for the QStyle::State_MouseOver case as follows: class MyDelegate : public…
linuxfever
  • 3,763
  • 2
  • 19
  • 43
2
votes
0 answers

How do I create an item delegate with buttons?

A list with 3 columns. First column for show/hide, second for the model name and the third for lock/unlock that will only appear when the item is clicked. How do you create something like this using QTableWidget and QStyledItemDelegate? I have…
TerribleDog
  • 1,237
  • 1
  • 8
  • 31
2
votes
1 answer

image with 3 possibility of value

I would like to personalize the 3rd columns to contain QCheckBox widgets. I would like those QCheckBox widgets to be customized with three icons: 1.png (Default state) | 2.png (Selected state) | 3.png (Disabled state). So I could do this using a…
user6223604
2
votes
1 answer

Custom QStyledItemDelegate to draw text with multiple colors

I want to display two columns inside a QTableWidget showing the differences between two stings (calculated by some Levenshtein Distance algorithms before). The parts are stored inside the data of each QTableWidgetItem, as a QStringList. The first…
Tobias Leupold
  • 1,512
  • 1
  • 16
  • 41
2
votes
1 answer

Drawing QTreeView items with QStyledItemDelegate

I have created a project based on the Simple Tree Model Example from the Qt examples list and edited its model so that some items can also be checked; this is how it looks like: I would like some of the items to be slightly moved to the left. So I…
Jacob Krieg
  • 2,834
  • 15
  • 68
  • 140
2
votes
1 answer

QListView items also showing the delegate editor even though the delegate is only added to the QTableView

I have a QListView and a QTableView both have the same QStandardItemModel. I have added a custom delegator to the QTableView. Now when I go to my QTableView and double-click an item I see the delegate editor widget, now if I go to my QListView and…
Sajal
  • 1,783
  • 1
  • 17
  • 21
2
votes
1 answer

QStyledItemDelegate how to make two widgets in one row?

I'm created a QStyledItemDelegate class in which I want to make some item checkable and some with two widgets. But it is not working right. What am I missing? This is what it looks like: See row 1, looks like the two widgets are there but they are…
YeP
  • 191
  • 5
  • 18
1
2
3
9 10