CopperSpice API  1.9.1
QSqlRelationalDelegate Class Reference

Delegate used to display and edit data from a QSqlRelationalTableModel. More...

Inheritance diagram for QSqlRelationalDelegate:
QItemDelegate QAbstractItemDelegate QObject

Public Methods

 QSqlRelationalDelegate (QObject *parent=nullptr)
 
 ~QSqlRelationalDelegate ()
 
QWidgetcreateEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
 
void setEditorData (QWidget *editor, const QModelIndex &index) const
 
void setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
 
- Public Methods inherited from QItemDelegate
 QItemDelegate (QObject *parent=nullptr)
 
 ~QItemDelegate ()
 
bool hasClipping () const
 
QItemEditorFactoryitemEditorFactory () const
 
void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
 
void setClipping (bool enabled)
 
void setItemEditorFactory (QItemEditorFactory *factory)
 
QSize sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const override
 
void updateEditorGeometry (QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override
 
- Public Methods inherited from QAbstractItemDelegate
 QAbstractItemDelegate (QObject *parent=nullptr)
 
virtual ~QAbstractItemDelegate ()
 
virtual void destroyEditor (QWidget *editor, const QModelIndex &index) const
 
virtual bool helpEvent (QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index)
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 

Additional Inherited Members

- Public Types inherited from QAbstractItemDelegate
enum  EndEditHint
 
- Public Signals inherited from QAbstractItemDelegate
void closeEditor (QWidget *editor, QAbstractItemDelegate::EndEditHint hint=NoHint)
 
void commitData (QWidget *editor)
 
void sizeHintChanged (const QModelIndex &index)
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 
- Public Slots inherited from QObject
void deleteLater ()
 
- Static Public Methods inherited from QAbstractItemDelegate
static QString elidedText (const QFontMetrics &fontMetrics, int width, Qt::TextElideMode mode, const QString &text)
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 
- Protected Methods inherited from QItemDelegate
void drawBackground (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
 
virtual void drawCheck (QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, Qt::CheckState state) const
 
virtual void drawDecoration (QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QPixmap &pixmap) const
 
virtual void drawDisplay (QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QString &text) const
 
virtual void drawFocus (QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect) const
 
bool editorEvent (QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override
 
bool eventFilter (QObject *object, QEvent *event) override
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Properties inherited from QItemDelegate
 clipping
 
- Properties inherited from QObject
 objectName
 

Detailed Description

The QSqlRelationalDelegate class provides a delegate which is used to display and edit data from a QSqlRelationalTableModel. Unlike the default delegate, QSqlRelationalDelegate provides a combobox for fields that are foreign keys into other tables. To use the class call QAbstractItemView::setItemDelegate() on the view with an instance of QSqlRelationalDelegate.

QTableView *view = new QTableView;
view->setModel(model);
view->setItemDelegate(new QSqlRelationalDelegate(view));
See also
QSqlRelationalTableModel, Model/View Architecture

Constructor & Destructor Documentation

QSqlRelationalDelegate::QSqlRelationalDelegate ( QObject parent = nullptr)
inlineexplicit

Constructs a QSqlRelationalDelegate object with the given parent.

QSqlRelationalDelegate::~QSqlRelationalDelegate ( )
inline

Destroys the QSqlRelationalDelegate object and frees any allocated resources.

Method Documentation

QWidget * QSqlRelationalDelegate::createEditor ( QWidget parent,
const QStyleOptionViewItem option,
const QModelIndex index 
) const
inlinevirtual

Reimplemented from QItemDelegate::createEditor()

void QSqlRelationalDelegate::setEditorData ( QWidget editor,
const QModelIndex index 
) const
inlinevirtual

Sets the data to be displayed and edited by the editor from the data model item specified by the model index. The default implementation stores the data in the user property for the given editor.

See also
QMetaProperty::isUser()

Reimplemented from QItemDelegate::setEditorData()

void QSqlRelationalDelegate::setModelData ( QWidget editor,
QAbstractItemModel model,
const QModelIndex index 
) const
inlinevirtual

Reimplemented from QItemDelegate::setModelData()