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  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QXmlNodeModelIndex Class Reference
[QtXmlPatterns module]

The QXmlNodeModelIndex class identifies a node in an XML node model subclassed from QAbstractXmlNodeModel. More...

 #include <QXmlNodeModelIndex>

This class is not part of the Qt GUI Framework Edition.

Note: All functions in this class are reentrant.

This class was introduced in Qt 4.4.


Public Types

enum DocumentOrder { Precedes, Follows, Is }
typedef List
enum NodeKind { Attribute, Text, Comment, Document, ..., ProcessingInstruction }

Public Functions

QXmlNodeModelIndex ()
QXmlNodeModelIndex ( const QXmlNodeModelIndex & other )
qint64 additionalData () const
qint64 data () const
void * internalPointer () const
bool isNull () const
const QAbstractXmlNodeModel * model () const
bool operator!= ( const QXmlNodeModelIndex & other ) const
bool operator== ( const QXmlNodeModelIndex & other ) const

Detailed Description

The QXmlNodeModelIndex class identifies a node in an XML node model subclassed from QAbstractXmlNodeModel.

QXmlNodeModelIndex is an index into an XML node model. It contains:

Because QXmlNodeModelIndex is intentionally a simple class, it doesn't have member functions for accessing the properties of nodes. For example, it doesn't have functions for getting a node's name or its list of attributes or child nodes. If you find that you need to retrieve this kind of information from your query results, there are two ways to proceed.

  • Send the output of your XQuery to an XML receiver, or
  • Let your XQuery do all the work to produce the desired result.

The second case is explained by example. Suppose you want to populate a list widget with the values of certain attributes from a set of result elements. You could write an XQuery to return the set of elements, and then you would write the code to iterate over the result elements, get their attributes, and extract the desired string values. But the simpler way is to just augment your XQuery to finding the desired attribute values. Then all you have to do is evaluate the XQuery using the version of QXmlQuery::evaluateTo() that populates a QStringList, which you can send directly to your widget.

QXmlNodeModelIndex doesn't impose any restrictions on the data value an QXmlNodeModelIndex should contain. The meaning of the data left to the associated node model. Because QXmlNodeModelIndex depends on a particular subclass of QAbstractXmlNodeModel for its existence, the only way you can create an instance of QXmlNodeModelIndex is by asking the node model to create one for you with QAbstractXmlNodeModel::createIndex(). Since that function is protected, it is usually a good ide to write a public function that creates a QXmlNodeModelIndex from arguments that are appropriate for your particular node model.

A default constructed node index is said to be null, i.e., isNull() returns true.

QXmlNodeModelIndex and QAbstractXmlNodeModel follow the same design pattern used for QModelIndex and QAbstractItemModel.


Member Type Documentation

enum QXmlNodeModelIndex::DocumentOrder

Identifies the specific node comparison operator that should be used.

ConstantValueDescription
QXmlNodeModelIndex::Precedes-1Signifies the \<\< operator. Test whether the first operand precedes the second in the document.
QXmlNodeModelIndex::Follows1Signifies the \>\> operator. Test whether the first operand follows the second in the document.
QXmlNodeModelIndex::Is0Signifies the is operator. Test whether two nodes have the same node identity.

typedef QXmlNodeModelIndex::List

Typedef for QList<QXmlNodeModelIndex>.

enum QXmlNodeModelIndex::NodeKind

Identifies a kind of node.

ConstantValueDescription
QXmlNodeModelIndex::Attribute1Identifies an attribute node
QXmlNodeModelIndex::Text64Identifies a text node
QXmlNodeModelIndex::Comment2Identifies a comment node
QXmlNodeModelIndex::Document4Identifies a document node
QXmlNodeModelIndex::Element8Identifies an element node
QXmlNodeModelIndex::Namespace16Identifies a namespace node
QXmlNodeModelIndex::ProcessingInstruction32Identifies a processing instruction.

Note that the optional XML declaration at very beginning of the XML document is not a processing instruction

See also QAbstractXmlNodeModel::kind().


Member Function Documentation

QXmlNodeModelIndex::QXmlNodeModelIndex ()

Default constructor. Creates an item that is null.

See also isNull().

QXmlNodeModelIndex::QXmlNodeModelIndex ( const QXmlNodeModelIndex & other )

Standard copy constructor. Creates a QXmlNodeModelIndex instance that is a copy of other.

qint64 QXmlNodeModelIndex::additionalData () const

Returns the second data value. The node index holds two data values. data() returns the first one.

See also data().

qint64 QXmlNodeModelIndex::data () const

Returns the first data value. The node index holds two data values. additionalData() returns the second one.

See also additionalData().

void * QXmlNodeModelIndex::internalPointer () const

Returns the first data value as a void* pointer.

See also additionalData().

bool QXmlNodeModelIndex::isNull () const

Returns true if this QXmlNodeModelIndex is a default constructed value, otherwise false.

A null QXmlNodeModelIndex doesn't represent any node and cannot be used in conjunction with QAbstractXmlNodeModel.

const QAbstractXmlNodeModel * QXmlNodeModelIndex::model () const

Returns the QAbstractXmlNodeModel that this node index refers to. QXmlNodeModelIndex does not own QAbstractXmlNodeModel and does not keep track of its lifetime, so this pointer will dangle if the QAbstractXmlNodeModel is deallocated first.

There is no setter for the node model because instances of QXmlNodeModelIndex instances are only created with QAbstractXmlNodeModel::createIndex().

bool QXmlNodeModelIndex::operator!= ( const QXmlNodeModelIndex & other ) const

Returns true if other is the same node as this.

bool QXmlNodeModelIndex::operator== ( const QXmlNodeModelIndex & other ) const

Returns true if this node is the same as other. This operator does not compare values, children, or names of nodes. It compares node identities, i.e., whether two nodes are from the same document and are found at the exact same place.

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 81
  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. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  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 6
Page suivante

Le Qt Quarterly au hasard

Logo

Se brancher au Web

Qt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. 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 4.6
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