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 implement buttons in a delegate PyQt

I am making a program for translating text (see screenshot) I have three classes class for displaying a window that edits item : class StyleDelegate(QStyledItemDelegate): def __init__(self, parent=None): super(StyleDelegate,…
Artem072
  • 123
  • 1
  • 8
0
votes
1 answer

How to let QLineEdit and QPushButton show in a column and style like this in a tableview in PyQt5?

I have 3 three pictures shown in below: How to let QLineEdit and QPushButton show in a column and style like this in a tableview in PyQt5? I have the following three pictures shown in below, I want to write a GUI which fulfill these feature by…
0
votes
1 answer

Get index of a ComboBoxItemDelegate in a QTableView

I created a ComboBoxItemDelegate which I added in the first column of a QTableView. I tried to use the currentIndexChanged(int index) method within a connect to get the index of the selected item in the ComboBox. This is what I wrote connect(cbd,…
PapyLudal
  • 1
  • 1
0
votes
1 answer

QTreeView with custom item delegate with Browse button

Working with the Qt5 framework (via pyQt5 with Python), I need to create a QTreeView widget with Parameter - Value columns, where the Value items for some rows must have an internal 'Browse' button to open a file browse dialog and place the selected…
0
votes
1 answer

Displaying QTableWidgetItem's text with different colors via a QStyledItemDelegate

I want to display parts of the text of a QTableWidgetItem in different colors (a part of it should be displayed red). What I found is using a QStyledItemDelegate, reimplementing the paint function and display a QTextDocument that uses the the item…
Tobias Leupold
  • 1,512
  • 1
  • 16
  • 41
0
votes
1 answer

Set size for a cell in QTreeView

I need to set: -minimum height for a cell in QTreeView (25px) -the height and width to fit with the content of each cell. I know that we can do it with sizeHint() in Delegate or with sizeHintRole in Model but still can not imagine how the functions…
0
votes
2 answers

How to override 'paint' function of custom delegate class to draw QSpinBox

I have added a custom delegator to the QTableView. When I double click on an item I see the editor widget which is a 'QSpinBox' and I am able to edit the value fine. This editor widget disappears once the focus is lost and I understand that. What I…
Sajal
  • 1,783
  • 1
  • 17
  • 21
0
votes
0 answers

Qt: QListView with QAbstractItemModel and QStyledItemDelegate takes long for adding items

I have a qt-application with QListView, a custom model and a class inherited from QStyledItemDelegate to show custom items. Unfortunately it takes to long (5 seconds) when I add approximately 6000 items. Do you have a hint/solution for my…
Mosa
  • 373
  • 1
  • 14
0
votes
2 answers

QListView only showing a single item in the view

I am utilizing the Model View Delegate framework used by Qt for displaying lists of objects with custom 'views' or layouts. Background: I require showing a country flag, country name, city name and an optional 'premium' rating star in a list, which…
CybeX
  • 2,060
  • 3
  • 48
  • 115
0
votes
1 answer

QStandardItem setBackground in delegate makes grid disappears in tableView

I am using a delegate to set one cell's background to be blue in tableView. The code like follows: void Delegate::setModelData(some parameters) { QStandardItem *item = model->item(modelIndex); item->setBackground(QBrush(Qt::blue)); …
Nick.Rhan
  • 167
  • 2
  • 7
0
votes
0 answers

Cannot edit custom items in QAbstractItemModel with custom delegate derived from QStyledItemDelegate

I am having a hard time implementing my own MVC approach in Qt5 framework. I created my own custom item class, derived my model class from QAbstractItemModel, derived my delegate class from QStyledItemDelegate and put everything together in a…
0
votes
2 answers

Unable to obtain sender object in slot of dataChanged signal of QAbstractItemModel

I have subclassed QAbstractItemModel and trying to retrieve a widget in slot of dataChanged signal. connect(model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(slotDataChanged(const QModelIndex&, const…
wazza
  • 313
  • 3
  • 19
0
votes
2 answers

How to set QStyleOptionButton like a checkbox with custom icons

I have a custom Delegate class which inherits from QStyledItemDelegate. In its paint() event, I would like to add QStyleOptionButton which should be checkable. Is it possible? For example, it denotes visibility property with an icon of eye; and when…
vicrucann
  • 1,703
  • 1
  • 24
  • 34
0
votes
1 answer

Why doesn't QTableView cell get focussed when I click on it?

I have created a QTableView and set a delegate which uses a slider to edit cells in column 2. I call openPersistentEditor on all cells in column 2: MinMaxSliderDelegate *minMaxSliderDelegate = new MinMaxSliderDelegate(this); table = new…
user1759557
  • 445
  • 4
  • 12
0
votes
1 answer

How to set QRect in the center of cell in QListVIew with QAbstractItemDelegate’s paint?

I have QListVIew and delegate to paint the list view. I paint some text int the center of cell. so I do it: void Delegate::paint(QPainter *painter, const QStyledOptionViewItem &option, const QModelIndex &index ) { . . . QRect…
tokafr
  • 109
  • 2
  • 12
1 2 3
9
10