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
1
vote
2 answers

How Qt manage the memory of an Widget pointer which is returned from the function QItemDelegate::createEditor()

I am checking the Qt example Spin Box Delegate example. In the example QWidget *SpinBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &/* option */, const QModelIndex &/* index */) const { QSpinBox *editor = new…
r0n9
  • 2,505
  • 1
  • 29
  • 43
1
vote
1 answer

QSqlTableModel with QTableView - consider DB defined constraint on edit

I have implemented an Oracle database. I use Qt for the GUI of my application and as an interface for the db. Setting up the connection to my db and displaying tables in a QTableView works fine. Edit of all cells is generally natively supported…
Basti Vagabond
  • 1,458
  • 1
  • 18
  • 26
1
vote
1 answer

How can I know when my QItemDelegate is the last item in the list?

My custom item delegate overrides this function: void TileToolDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const Everything works fine and draws fine except, for some reason,…
Jamin Grey
  • 10,151
  • 6
  • 39
  • 52
1
vote
1 answer

Qt event for delegate in table

Question/Issue I tried reimplementing the event method in a custom delegate to handle clicks. The delegate is used to render table cells in a table view. However, I do not get any events for the delegate (the method is never called according to the…
ted
  • 4,791
  • 5
  • 38
  • 84
1
vote
1 answer

draw background on custom QStyledItemDelegate like

I have a table and am trying to add a custom delegate following the example from the qt documentation. However, while the background color seems to be correct the overlay seems to be missing, in case the row is selected (Note the difference in the…
ted
  • 4,791
  • 5
  • 38
  • 84
1
vote
1 answer

Qt: QTreeView display two string on a row

I'm using Qt 5.4 and looking for a way to display two string on a single row like this picture: But the closest result I can achieve is this (with two rows), and it looks rather horrible: DevicesAndPlaylistModel.h #ifndef…
CheshireChild
  • 148
  • 1
  • 8
1
vote
4 answers

Set QItemDelegate on a particular QTreeWidgetItem

Is it possible to set a QItemDelegate on a particular QTreeWidgetItem? I need to color some of the QTreeWidgetItems with a particular color. I assume it is possible as we have QAbstractItemView::setItemDelegateForRow but I can't figure out how. I…
Jacob Krieg
  • 2,834
  • 15
  • 68
  • 140
1
vote
1 answer

QListView with custom item => mouse events are propagated

I would like to use a QListView with custom widgets that contain QSlider and QSpinBox widgets. I succeeded in creating the QListView with a new custom item delegate that displays the custom widgets but the mouse events are not propagated to the…
A.G.
  • 1,279
  • 1
  • 11
  • 28
1
vote
1 answer

Qt - Triggering an event when selection of abstract item delegate changes

I am trying to make a tableview with a row which has a separate dropdown for each column. The user can only select a combination of values. That is, if the user selects "A" from the first drop down, the values in the other drop downs should be…
jm.
  • 179
  • 1
  • 3
  • 13
1
vote
2 answers

How does one paint the entire row's background in a QStyledItemDelegate?

I have a QTableView which I am setting a custom QStyledItemDelegate on. In addition to the custom item painting, I want to style the row's background color for the selection/hovered states. The look I am going for is something like this KGet…
Casey
  • 6,166
  • 3
  • 35
  • 42
1
vote
0 answers

Qt, how to emit signal to parent widget?

Hi i have created a widget to use it in QTableWidget this Widget is a simple QComboBox class ComboDelegate(QtGui.QItemDelegate): """ A delegate that places a fully functioning QComboBox in every cell of the column to which it's applied …
Elteroooo
  • 2,913
  • 3
  • 33
  • 40
1
vote
1 answer

Make the delegate QtComboBox able to detect clicks

I am new to Qt. I have a table with a delegate combo box as the second column. I wanted to detect click on the combo box. I thought of one approach : add the combo box as a private variable in the ComboBoxDelegate and adding a public slot as void…
PDH
  • 381
  • 1
  • 4
  • 13
1
vote
1 answer

QItemDelegate with custom widgets

I'm having problems with my QTableView and QItemDelegate classes. For one column my delegate creates a simple combo box and everything works just fine. For my 2nd column I need a widget that has two combo boxes in a single widget. I've written the…
1
vote
2 answers

In reimplemented paint function of QItemDelegate, setFont is not working

I have reimplemented paint() function for QTreeWidget, I want to show data of second column bold, but it doesn't work. How can i fix it? void extendedQItemDelegate::paint(QPainter *painter, const…
mari
  • 417
  • 1
  • 6
  • 21
1
vote
0 answers

Best Practice: QDataWidgetMapper for nested widgets, or extend QAbstractItemView with delegates

My data is loaded from an XML file, and is certainly hierarchical. Adapting the data to work with Qt's Model/View framework seems to be straight forward. However, the XML nodes are not primitive objects, like numbers or strings. I like to display…
Marian
  • 351
  • 2
  • 12