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  · 

QAbstractTextDocumentLayout Class Reference
[QtGui module]

The QAbstractTextDocumentLayout class is an abstract base class used to implement custom layouts for QTextDocuments. More...

 #include <QAbstractTextDocumentLayout>

Inherits QObject.

Inherited by QPlainTextDocumentLayout.

Note: All the functions in this class are reentrant.

Public Types

Public Functions

  • 29 public functions inherited from QObject

Signals

Protected Functions

  • virtual void documentChanged ( int position, int charsRemoved, int charsAdded ) = 0
  • virtual void drawInlineObject ( QPainter * painter, const QRectF & rect, QTextInlineObject object, int posInDocument, const QTextFormat & format )
  • QTextCharFormat format ( int position )
  • virtual void positionInlineObject ( QTextInlineObject item, int posInDocument, const QTextFormat & format )
  • virtual void resizeInlineObject ( QTextInlineObject item, int posInDocument, const QTextFormat & format )
  • 7 protected functions inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 5 static public members inherited from QObject

Detailed Description

The QAbstractTextDocumentLayout class is an abstract base class used to implement custom layouts for QTextDocuments.

The standard layout provided by Qt can handle simple word processing including inline images, lists and tables.

Some applications, e.g., a word processor or a DTP application might need more features than the ones provided by Qt's layout engine, in which case you can subclass QAbstractTextDocumentLayout to provide custom layout behavior for your text documents.

An instance of the QAbstractTextDocumentLayout subclass can be installed on a QTextDocument object with the setDocumentLayout() function.

You can insert custom objects into a QTextDocument; see the QTextObjectInterface class description for details.

See also QTextObjectInterface.


Member Function Documentation

QAbstractTextDocumentLayout::QAbstractTextDocumentLayout ( QTextDocument * document )

Creates a new text document layout for the given document.

QString QAbstractTextDocumentLayout::anchorAt ( const QPointF & position ) const

Returns the reference of the anchor the given position, or an empty string if no anchor exists at that point.

QRectF QAbstractTextDocumentLayout::blockBoundingRect ( const QTextBlock & block ) const   [pure virtual]

Returns the bounding rectangle of block.

QTextDocument * QAbstractTextDocumentLayout::document () const

Returns the text document that this layout is operating on.

void QAbstractTextDocumentLayout::documentChanged ( int position, int charsRemoved, int charsAdded )   [pure virtual protected]

This function is called whenever the contents of the document change. A change occurs when text is inserted, removed, or a combination of these two. The change is specified by position, charsRemoved, and charsAdded corresponding to the starting character position of the change, the number of characters removed from the document, and the number of characters added.

For example, when inserting the text "Hello" into an empty document, charsRemoved would be 0 and charsAdded would be 5 (the length of the string).

Replacing text is a combination of removing and inserting. For example, if the text "Hello" gets replaced by "Hi", charsRemoved would be 5 and charsAdded would be 2.

For subclasses of QAbstractTextDocumentLayout, this is the central function where a large portion of the work to lay out and position document contents is done.

For example, in a subclass that only arranges blocks of text, an implementation of this function would have to do the following:

  • Determine the list of changed QTextBlock(s) using the parameters provided.
  • Each QTextBlock object's corresponding QTextLayout object needs to be processed. You can access the QTextBlock's layout using the QTextBlock::layout() function. This processing should take the document's page size into consideration.
  • If the total number of pages changed, the pageCountChanged() signal should be emitted.
  • If the total size changed, the documentSizeChanged() signal should be emitted.
  • The update() signal should be emitted to schedule a repaint of areas in the layout that require repainting.

See also QTextLayout.

QSizeF QAbstractTextDocumentLayout::documentSize () const   [pure virtual]

Returns the total size of the document's layout.

This information can be used by display widgets to update their scroll bars correctly.

See also documentSizeChanged() and QTextDocument::pageSize.

void QAbstractTextDocumentLayout::documentSizeChanged ( const QSizeF & newSize )   [signal]

This signal is emitted when the size of the document layout changes to newSize.

Subclasses of QAbstractTextDocumentLayout should emit this signal when the document's entire layout size changes. This signal is useful for widgets that display text documents since it enables them to update their scroll bars correctly.

See also documentSize().

void QAbstractTextDocumentLayout::draw ( QPainter * painter, const PaintContext & context )   [pure virtual]

Draws the layout with the given painter using the given context.

void QAbstractTextDocumentLayout::drawInlineObject ( QPainter * painter, const QRectF & rect, QTextInlineObject object, int posInDocument, const QTextFormat & format )   [virtual protected]

This function is called to draw the inline object, object, with the given painter within the rectangle specified by rect using the specified text format.

posInDocument specifies the position of the object within the document.

The default implementation calls drawObject() on the object handlers. This function is called only within Qt. Subclasses can reimplement this function to customize the drawing of inline objects.

See also draw().

QTextCharFormat QAbstractTextDocumentLayout::format ( int position )   [protected]

Returns the character format that is applicable at the given position.

QRectF QAbstractTextDocumentLayout::frameBoundingRect ( QTextFrame * frame ) const   [pure virtual]

Returns the bounding rectangle of frame.

QTextObjectInterface * QAbstractTextDocumentLayout::handlerForObject ( int objectType ) const

Returns a handler for objects of the given objectType.

int QAbstractTextDocumentLayout::hitTest ( const QPointF & point, Qt::HitTestAccuracy accuracy ) const   [pure virtual]

Returns the cursor postion for the given point with the specified accuracy. Returns -1 if no valid cursor position was found.

int QAbstractTextDocumentLayout::pageCount () const   [pure virtual]

Returns the number of pages contained in the layout.

See also pageCountChanged().

void QAbstractTextDocumentLayout::pageCountChanged ( int newPages )   [signal]

This signal is emitted when the number of pages in the layout changes; newPages is the updated page count.

Subclasses of QAbstractTextDocumentLayout should emit this signal when the number of pages in the layout has changed. Changes to the page count are caused by changes to the layout or the document content itself.

See also pageCount().

QPaintDevice * QAbstractTextDocumentLayout::paintDevice () const

Returns the paint device used to render the document's layout.

See also setPaintDevice().

void QAbstractTextDocumentLayout::positionInlineObject ( QTextInlineObject item, int posInDocument, const QTextFormat & format )   [virtual protected]

Lays out the inline object item using the given text format.

posInDocument specifies the position of the object within the document.

The default implementation does nothing. This function is called only within Qt. Subclasses can reimplement this function to customize the position of inline objects.

See also drawInlineObject().

void QAbstractTextDocumentLayout::registerHandler ( int objectType, QObject * component )

Registers the given component as a handler for items of the given objectType.

Note: registerHandler() has to be called once for each object type. This means that there is only one handler for multiple replacement characters of the same object type.

void QAbstractTextDocumentLayout::resizeInlineObject ( QTextInlineObject item, int posInDocument, const QTextFormat & format )   [virtual protected]

Sets the size of the inline object item corresponding to the text format.

posInDocument specifies the position of the object within the document.

The default implementation resizes the item to the size returned by the object handler's intrinsicSize() function. This function is called only within Qt. Subclasses can reimplement this function to customize the resizing of inline objects.

void QAbstractTextDocumentLayout::setPaintDevice ( QPaintDevice * device )

Sets the paint device used for rendering the document's layout to the given device.

See also paintDevice().

void QAbstractTextDocumentLayout::update ( const QRectF & rect = QRectF( 0., 0., 1000000000., 1000000000. ) )   [signal]

This signal is emitted when the rectangle rect has been updated.

Subclasses of QAbstractTextDocumentLayout should emit this signal when the layout of the contents change in order to repaint.

void QAbstractTextDocumentLayout::updateBlock ( const QTextBlock & block )   [signal]

This signal is emitted when the specified block has been updated.

Subclasses of QAbstractTextDocumentLayout should emit this signal when the layout of block has changed in order to repaint.

This function was introduced in Qt 4.4.

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 103
  2. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 56
  3. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 90
  4. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 31
  5. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 11
Page suivante
  1. Linus Torvalds : le "C++ est un langage horrible", en justifiant le choix du C pour le système de gestion de version Git 100
  2. Comment prendre en compte l'utilisateur dans vos applications ? Pour un développeur, « 90 % des utilisateurs sont des idiots » 231
  3. Quel est LE livre que tout développeur doit lire absolument ? Celui qui vous a le plus marqué et inspiré 96
  4. Apple cède et s'engage à payer des droits à Nokia, le conflit des brevets entre les deux firmes s'achève 158
  5. Nokia porte à nouveau plainte contre Apple pour violation de sept nouveaux brevets 158
  6. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 103
  7. Quel est le code dont vous êtes le plus fier ? Pourquoi l'avez-vous écrit ? Et pourquoi vous a-t-il donné autant de satisfaction ? 83
Page suivante

Le Qt Labs au hasard

Logo

UTF-8, Latin1 et charsets

Les Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. 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.5
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