\snippet itemviews/spinboxdelegate/delegate.cpp 0
- Since the delegate is a subclass of QItemDelegate, the data it retrieves
+ Since the delegate is a subclass of QStyledItemDelegate, the data it retrieves
from the model is displayed in a default style, and we do not need to
provide a custom \c paintEvent().
The table view is informed about the delegate, and will use it to
display each of the items. Since the delegate is a subclass of
- QItemDelegate, each cell in the table will be rendered using standard
+ QStyledItemDelegate, each cell in the table will be rendered using standard
painting operations.
We insert some arbitrary data into the model for demonstration purposes:
//! [0]
SpinBoxDelegate::SpinBoxDelegate(QObject *parent)
- : QItemDelegate(parent)
+ : QStyledItemDelegate(parent)
{
}
//! [0]
const QModelIndex &/* index */) const
{
QSpinBox *editor = new QSpinBox(parent);
+ editor->setFrame(false);
editor->setMinimum(0);
editor->setMaximum(100);
#ifndef DELEGATE_H
#define DELEGATE_H
-#include <QItemDelegate>
+#include <QStyledItemDelegate>
#include <QModelIndex>
#include <QObject>
#include <QSize>
#include <QSpinBox>
//! [0]
-class SpinBoxDelegate : public QItemDelegate
+class SpinBoxDelegate : public QStyledItemDelegate
{
Q_OBJECT