Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Fonctions  · 

QSqlFieldInfo Class Reference
[sql module]

The QSqlFieldInfo class stores meta data associated with a SQL field. More...

#include <qsqlfield.h>

List of all member functions.

Public Members


Detailed Description

The QSqlFieldInfo class stores meta data associated with a SQL field.

QSqlFieldInfo objects only store meta data; field values are stored in QSqlField objects.

All values must be set in the constructor, and may be retrieved using isRequired(), type(), length(), precision(), defaultValue(), name(), isGenerated() and typeID().

See also Database Classes.


Member Function Documentation

QSqlFieldInfo::QSqlFieldInfo ( const QString & name = QString::null, QVariant::Type typ = QVariant::Invalid, int required = -1, int len = -1, int prec = -1, const QVariant & defValue = QVariant ( ), int typeID = 0, bool generated = TRUE, bool trim = FALSE, bool calculated = FALSE )

Constructs a QSqlFieldInfo with the following parameters:
name the name of the field.
typ the field's type in a QVariant.
required greater than 0 if the field is required, 0 if its value can be NULL and less than 0 if it cannot be determined whether the field is required or not.
len the length of the field. Note that for non-character types some databases return either the length in bytes or the number of digits. -1 signifies that the length cannot be determined.
prec the precision of the field, or -1 if the field has no precision or it cannot be determined.
defValue the default value that is inserted into the table if none is specified by the user. QVariant() if there is no default value or it cannot be determined.
typeID the internal typeID of the database system (only useful for low-level programming). 0 if unknown.
generated TRUE indicates that this field should be included in auto-generated SQL statments, e.g. in QSqlCursor.
trim TRUE indicates that widgets should remove trailing whitespace from character fields. This does not affect the field value but only its representation inside widgets.
calculated TRUE indicates that the value of this field is calculated. The value of calculated fields can by modified by subclassing QSqlCursor and overriding QSqlCursor::calculateField().

QSqlFieldInfo::QSqlFieldInfo ( const QSqlFieldInfo & other )

Constructs a copy of other.

QSqlFieldInfo::QSqlFieldInfo ( const QSqlField & other, bool generated = TRUE )

Creates a QSqlFieldInfo object with the type and the name of the QSqlField other. If generated is TRUE this field will be included in auto-generated SQL statments, e.g. in QSqlCursor.

QSqlFieldInfo::~QSqlFieldInfo () [virtual]

Destroys the object and frees any allocated resources.

QVariant QSqlFieldInfo::defaultValue () const

Returns the field's default value or an empty QVariant if the field has no default value or the value couldn't be determined. The default value is the value inserted in the database when it is not explicitly specified by the user.

bool QSqlFieldInfo::isCalculated () const

Returns TRUE if the field is calculated; otherwise returns FALSE.

See also setCalculated().

bool QSqlFieldInfo::isGenerated () const

Returns TRUE if the field should be included in auto-generated SQL statments, e.g. in QSqlCursor; otherwise returns FALSE.

See also setGenerated().

int QSqlFieldInfo::isRequired () const

Returns a value greater than 0 if the field is required (NULL values are not allowed), 0 if it isn't required (NULL values are allowed) or less than 0 if it cannot be determined whether the field is required or not.

bool QSqlFieldInfo::isTrim () const

Returns TRUE if trailing whitespace should be removed from character fields; otherwise returns FALSE.

See also setTrim().

int QSqlFieldInfo::length () const

Returns the field's length. For fields storing text the return value is the maximum number of characters the field can hold. For non-character fields some database systems return the number of bytes needed or the number of digits allowed. If the length cannot be determined -1 is returned.

QString QSqlFieldInfo::name () const

Returns the name of the field in the SQL table.

Examples: sql/overview/subclass3/main.cpp and sql/overview/subclass4/main.cpp.

QSqlFieldInfo & QSqlFieldInfo::operator= ( const QSqlFieldInfo & other )

Assigns other to this field info and returns a reference to it.

bool QSqlFieldInfo::operator== ( const QSqlFieldInfo & f ) const

Returns TRUE if this fieldinfo is equal to f; otherwise returns FALSE.

Two field infos are considered equal if all their attributes match.

int QSqlFieldInfo::precision () const

Returns the field's precision or -1 if the field has no precision or it cannot be determined.

void QSqlFieldInfo::setCalculated ( bool calc ) [virtual]

calc set to TRUE indicates that this field is a calculated field. The value of calculated fields can by modified by subclassing QSqlCursor and overriding QSqlCursor::calculateField().

See also isCalculated().

void QSqlFieldInfo::setGenerated ( bool gen ) [virtual]

gen set to FALSE indicates that this field should not appear in auto-generated SQL statements (for example in QSqlCursor).

See also isGenerated().

void QSqlFieldInfo::setTrim ( bool trim ) [virtual]

If trim is TRUE widgets should remove trailing whitespace from character fields. This does not affect the field value but only its representation inside widgets.

See also isTrim().

QSqlField QSqlFieldInfo::toField () const

Returns an empty QSqlField based on the information in this QSqlFieldInfo.

QVariant::Type QSqlFieldInfo::type () const

Returns the field's type or QVariant::Invalid if the type is unknown.

int QSqlFieldInfo::typeID () const

Returns the internal type identifier as returned from the database system. The return value is 0 if the type is unknown.

Warning: This information is only useful for low-level database programming and is not database independent.


This file is part of the Qt toolkit. Copyright © 1995-2003 Trolltech. All Rights Reserved.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 94
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 42
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 7
Page suivante

Le blog Digia au hasard

Logo

Créer des applications avec un style Metro avec Qt, exemples en QML et C++, un article de Digia Qt traduit par Thibaut Cuvelier

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 3.2
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web