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  · 

QTextBoundaryFinder Class Reference
[QtCore module]

The QTextBoundaryFinder class provides a way of finding Unicode text boundaries in a string. More...

 #include <QTextBoundaryFinder>

Note: All functions in this class are reentrant.

This class was introduced in Qt 4.4.


Public Types

enum BoundaryReason { NotAtBoundary, StartWord, EndWord }
flags BoundaryReasons
enum BoundaryType { Grapheme, Word, Line, Sentence }

Public Functions

QTextBoundaryFinder ()
QTextBoundaryFinder ( const QTextBoundaryFinder & other )
QTextBoundaryFinder ( BoundaryType type, const QString & string )
QTextBoundaryFinder ( BoundaryType type, const QChar * chars, int length, unsigned char * buffer = 0, int bufferSize = 0 )
~QTextBoundaryFinder ()
BoundaryReasons boundaryReasons () const
bool isAtBoundary () const
bool isValid () const
int position () const
void setPosition ( int position )
QString string () const
void toEnd ()
int toNextBoundary ()
int toPreviousBoundary ()
void toStart ()
BoundaryType type () const
QTextBoundaryFinder & operator= ( const QTextBoundaryFinder & other )

Detailed Description

The QTextBoundaryFinder class provides a way of finding Unicode text boundaries in a string.

QTextBoundaryFinder allows to find Unicode text boundaries in a string, similar to the Unicode text boundary specification (see http://www.unicode.org/reports/tr29/tr29-11.html).

QTextBoundaryFinder can operate on a QString in four possible modes depending on the value of BoundaryType.

Units of Unicode characters that make up what the user thinks of as a character or basic unit of the language are here called Grapheme clusters. The two unicode characters 'A' + diaeresis do for example form one grapheme cluster as the user thinks of them as one character, yet it is in this case represented by two unicode code points.

Word boundaries are there to locate the start and end of what a language considers to be a word.

Line break boundaries give possible places where a line break might happen and sentence boundaries will show the beginning and end of whole sentences.


Member Type Documentation

enum QTextBoundaryFinder::BoundaryReason
flags QTextBoundaryFinder::BoundaryReasons

ConstantValueDescription
QTextBoundaryFinder::NotAtBoundary0The boundary finder is not at a boundary position.
QTextBoundaryFinder::StartWord1The boundary finder is at the start of a word.
QTextBoundaryFinder::EndWord2The boundary finder is at the end of a word.

The BoundaryReasons type is a typedef for QFlags<BoundaryReason>. It stores an OR combination of BoundaryReason values.

enum QTextBoundaryFinder::BoundaryType

ConstantValueDescription
QTextBoundaryFinder::Grapheme0Finds a grapheme which is the smallest boundary. It including letters, punctation marks, numerals and more.
QTextBoundaryFinder::Word1Finds a word.
QTextBoundaryFinder::Line2Finds possible positions for breaking the text into multiple lines.
QTextBoundaryFinder::Sentence3Finds sentence boundaries. These include periods, question marks etc.


Member Function Documentation

QTextBoundaryFinder::QTextBoundaryFinder ()

Constructs an invalid QTextBoundaryFinder object.

QTextBoundaryFinder::QTextBoundaryFinder ( const QTextBoundaryFinder & other )

Copies the QTextBoundaryFinder object, other.

QTextBoundaryFinder::QTextBoundaryFinder ( BoundaryType type, const QString & string )

Creates a QTextBoundaryFinder object of type operating on string.

QTextBoundaryFinder::QTextBoundaryFinder ( BoundaryType type, const QChar * chars, int length, unsigned char * buffer = 0, int bufferSize = 0 )

Creates a QTextBoundaryFinder object of type operating on chars with length.

buffer is an optional working buffer of size bufferSize you can pass to the QTextBoundaryFinder. If the buffer is large enough to hold the working data required, it will use this instead of allocating its own buffer.

Warning: QTextBoundaryFinder does not create a copy of chars. It is the application programmer's responsability to ensure the array is allocated for as long as the QTextBoundaryFinder object stays alive. The same applies to buffer.

QTextBoundaryFinder::~QTextBoundaryFinder ()

Destructs the QTextBoundaryFinder object.

BoundaryReasons QTextBoundaryFinder::boundaryReasons () const

Returns the reasons for the boundary finder to have chosen the current position as a boundary.

bool QTextBoundaryFinder::isAtBoundary () const

Returns true if the object's position() is currently at a valid text boundary.

bool QTextBoundaryFinder::isValid () const

Returns true if the text boundary finder is valid; otherwise returns false. A default QTextBoundaryFinder is invalid.

int QTextBoundaryFinder::position () const

Returns the current position of the QTextBoundaryFinder.

The range is from 0 (the beginning of the string) to the length of the string inclusive.

See also setPosition().

void QTextBoundaryFinder::setPosition ( int position )

Sets the current position of the QTextBoundaryFinder to position.

If position is out of bounds, it will be bound to only valid positions. In this case, valid positions are from 0 to the length of the string inclusive.

See also position().

QString QTextBoundaryFinder::string () const

Returns the string the QTextBoundaryFinder object operates on.

void QTextBoundaryFinder::toEnd ()

Moves the finder to the end of the string. This is equivalent to setPosition(string.length()).

See also setPosition() and position().

int QTextBoundaryFinder::toNextBoundary ()

Moves the QTextBoundaryFinder to the next boundary position and returns that position.

Returns -1 is there is no next boundary.

int QTextBoundaryFinder::toPreviousBoundary ()

Moves the QTextBoundaryFinder to the previous boundary position and returns that position.

Returns -1 is there is no previous boundary.

void QTextBoundaryFinder::toStart ()

Moves the finder to the start of the string. This is equivalent to setPosition(0).

See also setPosition() and position().

BoundaryType QTextBoundaryFinder::type () const

Returns the type of the QTextBoundaryFinder.

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

Assigns the object, other, to another QTextBoundaryFinder object.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. Microsoft ouvre aux autres compilateurs C++ AMP, la spécification pour la conception d'applications parallèles C++ utilisant le GPU 22
  2. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  3. RIM : « 13 % des développeurs ont gagné plus de 100 000 $ sur l'AppWord », Qt et open-source au menu du BlackBerry DevCon Europe 0
  4. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 12
  5. 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
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
Page suivante

Le Qt Developer Network au hasard

Logo

Compiler l'add-in Qt de Visual Studio

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. 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