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
1
vote
1 answer

How to access another index inside paint() function of delegate?

When mouse is over a cell of a table, I need to create an effect for the whole row of that cell. That means I need to access to another index. In this case I made a for loop, run from the first column to last column of the table and set effect for…
trangan
  • 341
  • 8
  • 22
1
vote
1 answer

Why does delegate not recognize the state mouseOver?

I created a delegate and need to recognize mouseOver state to build an effect. But it does not work. When I my table appears, the output is like this When i move the mouse over the table, the output is like this I don't see the state MouseOver.…
gnase
  • 580
  • 2
  • 10
  • 25
1
vote
2 answers

How to popup QCompleter on entering cell editing in QTableWidget

I have a QTableWidget with custom QStyledItemDelegate and when enter in cell editing, I want to popup a completer but it doesn't appear. The setup of delegate: tableWidget.setItemDelegate(new DelegateLineEdit()); My custom class: class…
thibsc
  • 3,747
  • 2
  • 18
  • 38
1
vote
1 answer

QStyledItemDelegate: differentiate the cause for closeEditor() or setModelData()

I'm using a QTableWidget and need some custom handling of the editing, so I set a QStyledItemDelegate on it. When the user finishes editing, the signal closeEditor() is emitted, which I connect to to process the entered data. This signal is both…
Tobias Leupold
  • 1,512
  • 1
  • 16
  • 41
1
vote
1 answer

Setting a particular cell with a color (red/green /yellow) on Qtableview

I been searching for how to set a color on a specific cell on a qtableview. Currently ,I am using the qt example frozen column to see how to set a color on a particular cell. I search on the forums about how to tell to use qitemdelegate or…
1
vote
0 answers

QStyledItemDelegate with QComboBox with QTableView control (how to pass signal)

I wonder if someone can put me in the right direction, with his/her wisdom and skill of Qt programming as I have following logic issue with my project: I am using three different controls of delegate with QtableView i. ProdIdDelegate public…
shylock
  • 41
  • 5
1
vote
1 answer

Qt ItemDelegate displayText() with a QTableWidget: How can I access the table index?

I display data in a QTableWidget in various number formats, depending on the setting of a combobox (outside QTableWidget). This works nicely by redefining the displayText() method of an ItemDelegate. I would also like to style / modify the displayed…
Chipmuenk
  • 607
  • 1
  • 7
  • 22
1
vote
0 answers

QStyledItemDelegate custom widget drawn incorrect, when scrolling

One of my earlier Question deals with a customized QStyledItemDelegate containing a QWidget with two QLabels side by side. I was really satisfied with the easy solution given by Joseph Ireland. Unfortunately, the given is solution is broken, but I…
Aleph0
  • 5,816
  • 4
  • 29
  • 80
1
vote
1 answer

Custom ItemDelegate for QListView in PySide: Items invisible

Question: Why does the Python-equivalent of this answer class CustomDelegate(QtGui.QStyledItemDelegate): def paint(self, painter, option, index): opt = QtGui.QStyleOptionViewItem(option) self.initStyleOption(opt, index) …
S818
  • 391
  • 3
  • 15
1
vote
2 answers

Custom QStyledItemDelegate - Applying Edits to Model

In my project, I subclassed QStyledItemDelegate and returned a custom editor from the createEditor function. QWidget* TagEditDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { …
mrg95
  • 2,371
  • 11
  • 46
  • 89
1
vote
0 answers

Qt5 QStyledItemDelegate on a QListView removes all the default style

I have some QIcon and QString pairs displayed in a QListview. The whole thing has been set up using the Qt Model/View Programming. I am displaying labeled icons in this QListView. Items are displayed using the IconMode, Snap and TopToBottom flags.…
Papipone
  • 1,083
  • 3
  • 20
  • 39
1
vote
0 answers

Qt TableWidget - The image that appears when you click the cell

I use a QTableWidget with two columns. The first column display images. The second column display text. I'm calling QBrush::setTexture on the first column, not the setIcon function. I want the first column images to change when I click on their cell…
1
vote
1 answer

draw background on custom QStyledItemDelegate like

I have a table and am trying to add a custom delegate following the example from the qt documentation. However, while the background color seems to be correct the overlay seems to be missing, in case the row is selected (Note the difference in the…
ted
  • 4,791
  • 5
  • 38
  • 84
1
vote
2 answers

Access pointer to QWidget(Combobox) of the customdelegate

I have derived a class from QStyledItemDelegate. I am using a QComboBox in this delegate. This delegate is used in QTableView. My question is, how can i change the index of the Combobox in the delegate programatically i.e how to access the pointer…
user1703942
  • 317
  • 3
  • 15
1
vote
1 answer

Adjusting the selection behaviour of QStandardItem with QStyledItemDelegate

I am using QStyledItemDelegate to style the items in my QTreeView. The roots of my treeview are not decorated. It's just a simple tree with relation similar to the one below: ColorBook1 Color1 Color2 ColorBook2 Color3 The parent and…
sajas
  • 1,599
  • 1
  • 17
  • 39