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

Draw adjustable text in QTableView cell

I need to subclass the QStyledItemDelegate of my QTableView. More particularly, I need to modify the display of a specific column. The cells in this column normally contains text. Here is a little part of my custom QStyledItemDelegate class: elif…
JPFrancoia
  • 4,866
  • 10
  • 43
  • 73
1
vote
2 answers

Having A Working QSqlRelationalDelegate With QSortFilterProxyModel

I am using QSortFilterProxyModels all the time. However, if a QSqlRelation is setup on the source model, along with a QSqlRelationalDelegate on the view, whenever the view is switched to the proxy model, the QSqlRelationalDelegate disappears,…
1
vote
1 answer

QLineEdit does not show text after setText

I am stumped. In the code below: class LineEdit(QtGui.QLineEdit): def __init__(self, value="", parent=None, commit=None): super(LineEdit, self).__init__(parent=parent) self.setText("blabla") self.commit = commit …
Lars
  • 1,869
  • 2
  • 14
  • 26
1
vote
0 answers

QTableView loses focus for no reason

I have been trying to figure out why this happens but in vain. I have a QTableView that has different delegates (QStyledItemDelegate inherited classes) for each column. I tested the delegates in another view and they work fine. My problem is that…
fonZ
  • 2,428
  • 4
  • 21
  • 40
1
vote
1 answer

How to unset all custom QStyledItemDelegates from QListView?

I set a few custom delegates in my list. When I do a reset of the model QListView::reset(); gets called but the delegates are not reset. Is this a bug, if not how can I reset all delegates? Iterating over all rows and set the delegates to nullptr…
ManuelSchneid3r
  • 15,850
  • 12
  • 65
  • 103
1
vote
1 answer

Set delegate for QTreeWidget header

I need to set delegate for QTreeWidget header or make it working with HTML tags using other ways. I set a delegate for QTreeWidget items using ui->tree->setItemDelegate(delegate); and it works. But setting a delegate to the header does not work…
Ufx
  • 2,595
  • 12
  • 44
  • 83
1
vote
1 answer

Delegate erasing text in QTreeView using QStandardItemModel

I'm having some difficulty adding a delegate to my QTreeView. I have added some QStandardItems through a model which works fine, but when I add the delegate, the text is erased and only the icons are visible. This is the code i'm using for my…
Simpsons
  • 476
  • 1
  • 7
  • 17
1
vote
2 answers

Qt delegate setting mouseover state for checkbox

I have a paint method in a delegate used in a QTableview where I add a checkbox indicator to a cell. Its very easy to set the mouseover state of the checkbox when I enter the cell by checking the option.state for the QStyle::State_MouseOver flag but…
kh25
  • 1,238
  • 1
  • 15
  • 33
1
vote
0 answers

Why QCompleter works differently with delegates?

I am trying to implement auto-completion for QLineEdit. Here see my code: #ifndef COMPLETER_H #define COMPLETER_H #include #include #include #include class Completer:public…
Eduard Rostomyan
  • 7,050
  • 2
  • 37
  • 76
1
vote
1 answer

closeEditor only accepts 2 arguments (2 given)

Does anyone know why I am getting the follow error: TypeError: closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint) only accepts 2 arguments, 2 given! I am using a QStyledItemDelegate so that I have more control over a table (QTableWidget())…
David Yee
  • 3,515
  • 25
  • 45
1
vote
0 answers

Delegate for a QComboBox not working for the default item

I am using a QComboBox to display some MAC addresses which come from a database as integer numbers. For displaying them in the more familiar "dotted octets" format, I created the following QStyledItemDelegate: class…
Claudio
  • 2,191
  • 24
  • 49
1
vote
1 answer

drawing icons in a table with QStyledItemDelegate paint()

I'm trying to implement a custom paint function for a QStyledItemDelegate subclass (QT4.8.2). I've reviewed the StarItemDelegate example, among others, and it appears to be pretty straightforward. The delegate is assigned to a column of the table…
Joel Graff
  • 239
  • 6
  • 14
1
vote
1 answer

QStyledItemDelegate and QStandardItem preventing change text , enable only select and copy

I have a simple QStandardItem and QTableView and QStyledItemDelegate. They have delegates , I would like to disable the possibility for user to change the content of a column in the table, and allow only select and copy. I guess it related to…
user63898
  • 29,839
  • 85
  • 272
  • 514
0
votes
0 answers

Adding gridlines to my tree view: Error thrown when moving mouse over lines

Below is a toy script that generates a tree view with gridlines. Any time I hove my mouse over the gridlines, an error is reported: QStyledItemDelegate.paint(painter, option, index) TypeError: descriptor 'paint' for…
DJames
  • 571
  • 3
  • 17
0
votes
1 answer

How to handle custom data show in QTableView?

I have a QTableView with custom model, delegate and data class. I want to show different widgets in my table based on data types. this is done in my delegate class. background and checkbox types are handled in show method of my model class. this is…