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

How to resize QTableWidgetItem to its editor size then to its text size using QStyledItemDelegate?

I created my own CustomDelegate class derived from QStyledItemDelegate: class CustomDelegate(QStyledItemDelegate): def __init__(self, parent): super().__init__(parent) def createEditor(self, parent, option, index): editor =…
Skryge
  • 81
  • 1
  • 9
0
votes
0 answers

QLineEdit delegate's setModelData always returns index of last delegate in table

Setup description Table in PySide created with QMainWindow - > QWidget -> QTableView -> TableModel (QAbstractTableModel) -> array[object] first column has QPushButton delegate ResetDelegate second column has QLineEdit delegate…
martin_h
  • 29
  • 5
0
votes
1 answer

QTableView not scrolling when mouse is at disabled delegate button

Setup description Table in PySide created with QMainWindow - > QWidget -> QTableView -> TableModel (QAbstractTableModel) -> array[[]] For second column is created ButtonDelegate(QStyledItemDelegate) Problem description If button in delegate is…
martin_h
  • 29
  • 5
0
votes
1 answer

How to get functional combobox in QTableView

As the title suggests I'm looking to get a combobox in a QTableView. I've looked at several other questions that deal with comboboxes in tableviews, but they mostly concern comboboxes as editors and that is not what I'm looking for. I would like …
mahkitah
  • 562
  • 1
  • 6
  • 19
0
votes
1 answer

QListView set Custom Editor via QStyledItemDelegate::createEditor

I want to show custom widget in each QListView cells (3 labels width different fonts and 2 tool buttons). The widget must handle mouse events for correct handling of the hover events and button clicks. (Therefore I cannot just draw it in…
Vladimir Bershov
  • 2,701
  • 2
  • 21
  • 51
0
votes
0 answers

How to get a Cell's coordinates in the delegate's painter by index/ column/row?

Note, I'm not asking about the current cell. I'm asking about getting some OTHER cell's position by row and column. I've set a delegate for my Qtableview to handle graphics. Inside my paint (self, painter: QPainter, option, index: QModelIndex): I…
0
votes
1 answer

QStyledItemDelegate tooltip handling (+ internal status)

I am using "fancy" QStyledItemDelegate for the first time to draw and control multiple buttons in a QTableView column. So far so good with the paint + editorEvent approach, but with two little issues/unresolved ideas: I can't understand how to…
Manu310
  • 158
  • 2
  • 12
0
votes
2 answers

QStyledItemDelegate's option is not updating

I ran into a problem while using PyQt5. I have a list with QStyledItemDelegate class painting its items. Here is the minimal reproducible example: import sys from PyQt5.QtCore import ( QAbstractListModel, Qt, QSize, QRect, …
Vladislav
  • 35
  • 7
0
votes
1 answer

Custom ComboBox using custom model and delegate

I have a list of items in the form (string, integer, bool), like so: [ ('Item 1', 12, True), ('Item 2', 156, True), ('Item 3', 19, False) ] which I'd like to display in a QComboBox in the following way: The first element of the tuple is…
0
votes
1 answer

Qt displayAlignment not aligning to the right

I am writing an application using PyQt. I am using QListView with QStyledItemDelegate and I need to align some items on the left and some on the right. All of them are aligned on the left by default. However, I still don't get how to align them on…
Vladislav
  • 35
  • 7
0
votes
2 answers

Change foreground color of items based on the item's text itself

I have a QTreeView with 5 columns and I set up a QComboBox delegate for 2 of them (columns 1 and 2). Both of them have the same delegate and they must have the same drop down list. Let's say the list is always: ["Next", "Stop"]. So far so good: the…
John Reds
  • 117
  • 14
0
votes
2 answers

QStyledItemDelegate: Add disabled check indicator

I'm using a QTreeView with a custom QStyledItemDelegate to display various parameter items. I want all of the items to have a check indicator, however some of the Checkboxes should be disabled (but still visible and set checked!). Here's the…
Alex
  • 95
  • 1
  • 10
0
votes
1 answer

Initial paint of QStyledItemDelegate has the wrong height

I am attempting to use a QStyledItemDelegate with my QListView to display rich text in the items. The first time the item is painted its height is too small. If I then mouse over the item it gets repainted with the correct height. Below are…
sourcenouveau
  • 29,356
  • 35
  • 146
  • 243
0
votes
1 answer

How to open editor outside of qlistview?

The QAbstractItemView::openPersistentEditor method calls the createEditor method reimplemented in a class inherited from the QStyledItemDelegate class. It opens a widget inside the current item. But my task is to show the editor widget in some…
alxprogger
  • 87
  • 5
0
votes
1 answer

Qt5 QListView set up items in a horizontal row instead of vertical list

I am setting up a QListView with a custom QStyledItemDelegate and I would like to have my items rendered so they are in a horizontal 'row'. Assuming our QListView has models that are "A", "B", and "C", the standard view will have them…
NuclearPeon
  • 5,743
  • 4
  • 44
  • 52