Questions tagged [qitemdelegate]

QItemDelegate is a Qt class which provides display and editing facilities for data items from a model.

The QItemDelegate class is one of the Model/View Classes and is part of Qt's model/view framework.

QItemDelegate can be used to provide custom display features and editor widgets for item views based on QAbstractItemView subclasses. Using a delegate for this purpose allows the display and editing mechanisms to be customized and developed independently from the model and view.

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

145 questions
5
votes
1 answer

QStyledItemDelegate drawing custom widget failed

In one of my projects I'm using a QTableWidget in order to display some complex computational results. In order to increase the readability of the table I'm in need to display two aligned values inside of a single table cell. Later on I want to…
Aleph0
  • 5,816
  • 4
  • 29
  • 80
5
votes
1 answer

QItemDelegate with custom view widget

Qt 5.5 has a virtual method to define a custom widget for editing mode: QWidget *createEditor(QWidget *parent,const QStyleOptionViewItem & option ,const QModelIndex & index ) const But how to use a custom widget to override the "view" mode? I saw…
Zelid
  • 6,905
  • 11
  • 52
  • 76
4
votes
3 answers

QStyledItemDelegate's sizeHint method not called for a QTableView row

I have QTableView using a QSqlQueryModel (it fetches data from SQLite). There is a QStyledItemDelegate subclass called MiniItemDelegate that I use as a delegate for the items. I set up a sizeHint() method like this: QSize…
user63898
  • 29,839
  • 85
  • 272
  • 514
4
votes
4 answers

How to make QCombobox painting item delegate for it's current Item? (Qt 4)

QCombobox set Item delegate not painting for current Item.. I am trying to create a combo box showing different line types (Solid, Dotted, Dash etc). Currently i am setting item delegate for its content so as to draw/paint line type instead of…
r4nj33t
4
votes
1 answer

Paint widget directly on QListView with QStyledItemDelegate::paint()

After hours of work, I'm able to paint a widget on QListView. However, the painting is done through a QPixmap. The widget appears, and I can see a progress bar. However, it's a little "pixelated" (due to using QPixmap). Is it possible to paint…
Sam Markus
  • 320
  • 3
  • 9
4
votes
2 answers

How to create combo-box QItemDelegate

I implemented the following delegate, to provide a combobox in a QTableView. The use case is to replace a column (key) that is generally meaningless for the user (e.g. a numerical id) with a text equivalent. The snippet below works (also for saving…
fralau
  • 3,279
  • 3
  • 28
  • 41
4
votes
1 answer

How to pass mousePressEvent from QItemDelegate to QTableView

The code creates a single QTableView. Left column is pre-populated with QLineEdits delegates. Right column is not populated with any delegates. When the left-column's delegated QLineEdit is clicked the 'clicked' signal is blocked by the delegated…
alphanumeric
  • 17,967
  • 64
  • 244
  • 392
4
votes
2 answers

How to add different types of delegates in QTreeView

I want to create same kind of QTreeView (not QTreeWidget) structure as shown in attached figure.. This is Property Editor of QT. I am using QT-4.6 On 2nd column, depending on different condition, I can have either a spin box, or a drop down or a…
Nishant Sharma
  • 341
  • 2
  • 5
  • 17
4
votes
1 answer

Qt ItemDelegate with a tool button: can't click

I use a custom widget for an item delegate. This widget is composed of a combobox and a tool button, see below for the source. Now when I use this widget in an item delegate, pressing on the tool button has no effect if the combobox has not the…
Denis Rouzaud
  • 2,412
  • 2
  • 26
  • 45
4
votes
1 answer

Height of editor in QItemDelegate

I have QListView with custom implementation of QItemDelegate. MyItemDelegate reimplements createEditor() to show custom widget. Size of widget is dependant on content. By default, each row height is about 20px (one row), but my editor has bigger…
developer
  • 319
  • 2
  • 13
3
votes
2 answers

Mystery: In Qt, why would editorEvent be called, but not createEditor?

I'm subclassing QAbstractItemDelegate. This is my code. Suggestions are welcome: QWidget *ParmDelegate::createWidget(Parm *p, const QModelIndex &index) const { QWidget *w; if (index.column() == 0) { w = new…
Neil G
  • 32,138
  • 39
  • 156
  • 257
3
votes
1 answer

Custom widget on QItemDelegate editor for QTableView

I have a QTableView showing a data from a custom model. I have a QItemDelegate for the edition on each of the cells. One column of the view has a custom widget comprised by a QLineEdit and a QCheckBox. When I click on the cells of this column the…
user20679
  • 442
  • 4
  • 17
3
votes
2 answers

Create PushButtons in QTableView with QStyledItemDelegate subclass

I have the exact same problem, but I will use the QTableView widget. I read this and was wondering if I can override the createEditor function to use for instance QFileDialog to get the new data. If this is possible, can anyone provide me with an…
Darkproduct
  • 1,062
  • 13
  • 28
3
votes
0 answers

align each column differently in QTableWidget

I need to create a table like this how can I align first column left, 2nd and 3rd columns center, and last column right sothat when someone put data in, it is automatically aligned as I want ? My first…
trangan
  • 341
  • 8
  • 22
3
votes
4 answers

Changing QCheckBox indicator rectangle color

I'm trying to change only the color of QCheckBox indicator rectangle. Currently I succeed to draw the right and the bottom line of the rectangle. Probably I'm doing something wrong here. Here is my…
Simon
  • 1,522
  • 2
  • 12
  • 24
1
2
3
9 10