QDjango
Loading...
Searching...
No Matches
Public Slots | Public Member Functions | Protected Member Functions | Properties | List of all members
QDjangoModel Class Reference

The QDjangoModel class is the base class for all models. More...

#include <QDjangoModel.h>

Inheritance diagram for QDjangoModel:

Public Slots

bool remove ()
 
bool save ()
 
QString toString () const
 

Public Member Functions

 QDjangoModel (QObject *parent=0)
 
QVariant pk () const
 
void setPk (const QVariant &pk)
 

Protected Member Functions

QObject * foreignKey (const char *name) const
 
void setForeignKey (const char *name, QObject *value)
 

Properties

QVariant pk
 

Detailed Description

The QDjangoModel class is the base class for all models.

To declare your own model, create a class which inherits QDjangoModel and declare the database fields as properties using the Q_PROPERTY macro. You must then register the class with QDjango using QDjango::registerModel().

You can provide options for the model using the Q_CLASSINFO macro as follows:

Q_CLASSINFO("__meta__", "keyword1=value1 .. keywordN=valueN")

The following keywords are recognised for model options:

You can also provide additional information about a field using the Q_CLASSINFO macro, in the form:

Q_CLASSINFO("field_name", "keyword1=value1 .. keywordN=valueN")

The following keywords are recognised for field options:

Constructor & Destructor Documentation

◆ QDjangoModel()

QDjangoModel::QDjangoModel ( QObject * parent = 0)

Construct a new QDjangoModel.

Parameters
parent

Member Function Documentation

◆ foreignKey()

QObject * QDjangoModel::foreignKey ( const char * name) const
protected

Retrieves the QDjangoModel pointed to by the given foreign-key.

Parameters
name

◆ pk()

QVariant QDjangoModel::pk ( ) const

Returns the primary key for this QDjangoModel.

◆ remove

bool QDjangoModel::remove ( )
slot

Deletes the QDjangoModel from the database.

Returns
true if deletion succeeded, false otherwise

◆ save

bool QDjangoModel::save ( )
slot

Saves the QDjangoModel to the database.

Returns
true if saving succeeded, false otherwise

◆ setForeignKey()

void QDjangoModel::setForeignKey ( const char * name,
QObject * value )
protected

Sets the QDjangoModel pointed to by the given foreign-key.

Parameters
name
value
Note
The QDjangoModel will not take ownership of the given value.

◆ setPk()

void QDjangoModel::setPk ( const QVariant & pk)

Sets the primary key for this QDjangoModel.

Parameters
pk

◆ toString

QString QDjangoModel::toString ( ) const
slot

Returns a string representation of the model instance.


The documentation for this class was generated from the following files: