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
37
votes
5 answers

QListView/QListWidget with custom items and custom item widgets

I'm writing a PyQt application and am having some trouble creating a custom list view. I'd like the list to contain arbitrary widgets (one custom widget in particular). How would I go about this? It seems that the alternative would be to create a…
Daniel Naab
  • 22,690
  • 8
  • 54
  • 55
23
votes
2 answers

QListWidget or QListView with QItemDelegate?

Let's say I need to display a list of items. Each item contains a QPushButton an image and some text. When a user clicks on the button something should happen (ie I need to get the signal). What is the right way to implement this in Qt? After some…
Mahadevan Sreenivasan
  • 1,144
  • 1
  • 9
  • 26
22
votes
2 answers

Qt - QTableView - Clickable button in table row

I require a button/link within a table row of a QTableView. This is to open a dialog to allow that row to be edited more efficiently. After hours of looking on the web I am yet to find a decent example. I am aware that this is likely to be done…
cweston
  • 11,297
  • 19
  • 82
  • 107
19
votes
3 answers

Qt Using Custom QItemDelegate for QTableView

I followed the Spin Box Delegate tutorial, which Qt provides, to try to implement my own QItemDelegate. It would be used to specify a QComboBox to represent data in a QTableView cell but it is not working. My biggest problem is that I don't know…
arnm
  • 1,705
  • 2
  • 19
  • 30
16
votes
1 answer

What is the difference between QItemDelegate and QStyledItemDelegate?

Both classes provide display and editing facilities for data items from a model. QStyledItemDelegate is newer and the Qt documentation about QItemDelegate states that : Note that QStyledItemDelegate has taken over the job of drawing Qt's item…
Nejat
  • 31,784
  • 12
  • 106
  • 138
12
votes
1 answer

Model - View - Controller in Qt

I understand more or less how does MPV works. But I don't get what classes: QAbstractItemModel QAbstractItemView QAbstractItemDelegate / QItemDelegate Can do for me? If that is relevant, I'm using QGraphicsScene / QGraphicsView with some elements…
Łukasz Lew
  • 48,526
  • 41
  • 139
  • 208
11
votes
4 answers

How do I tell Qt to always show an editor in a QTableView?

I've got a QTableView for which I want to display the last column always in edit mode. (It's a QComboBox where the user should be able to always change the value.) I think I've seen the solution in the Qt documentation, but I can't find it anymore.…
Georg Schölly
  • 124,188
  • 49
  • 220
  • 267
10
votes
2 answers

A ListView of checkboxes in PyQt

I want to display a QListView where each item is a checkbox with some label. The checkboxes should be visible at all times. One way I can think of is using a custom delegate and QAbstractListModel. Are there simpler ways? Can you provide the…
Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412
9
votes
1 answer

Clickable elements or child widgets inside custom-painted delegate

I have a QListView, where I display items using a custom delegate with custom painting. Within each item (i.e. each list row) I want to be able to show a couple of "hyperlinks" which the user could click on and which would then call on some…
Weetu
  • 1,761
  • 12
  • 15
9
votes
1 answer

Why pressing of "Tab" key emits only QEvent::ShortcutOverride event?

Background I've made a custom widget with QLineEdit and several QPushButtons to use it with custom item delegate: class LineEditor : public QWidget { public: explicit LineEditor(QWidget *parent = 0) : QWidget(parent) { setLayout(new…
fasked
  • 3,555
  • 1
  • 19
  • 36
7
votes
6 answers

checkbox and itemdelegate in a tableview

I'm doing an implementation of a CheckBox that inherits from QitemDelegate, to put it into a QTableView. the problem is that I get when inserted flush left and I need it centered. As I understand the method that is responsible for the Paint. I have…
jackajack
  • 153
  • 1
  • 1
  • 11
6
votes
1 answer

Qt QTableView draw border around active cells

I'm trying to implement behavior similar Excel in a QTableView, where a border is painted around the entire current selection. I have tried this what feels like a hundred different ways and keep getting problems. I can draw the border easily…
buck
  • 1,502
  • 1
  • 20
  • 23
6
votes
1 answer

Conditionally change color of files in QListView connected to QFileSystemModel

I'm having a QListView with a QFileSystemModel. Based on a selection in a QTreeView, the QListView shows the content of the folder. Now I need to change the color of the filenames depending on some condition. The initial idea would be to iterate…
ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712
6
votes
2 answers

Show other data in QTableView with QItemDelegate

I have a QTableView connected with an QSqlTableModel. In the first column, there are only dates at this format: 2010-01-02 I want this column to show the date at this format (but without changing the real data): 02.01.2010 I know that I have to…
Berschi
  • 2,605
  • 8
  • 36
  • 51
5
votes
1 answer

How to get QTreeView cell width inside QItemDelegate sizeHint()?

I have a custom QItemDelegate drawing text within a QTreeView. In paint(), I get the size of the cell from the style. I then draw the text, with wordwrap, using the current cell's width. In sizeHint(), I really only want to calculate the height. …
user297250
1
2 3
9 10