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  ·  Modules  ·  Fonctions  · 

Q3TextBrowser Class Reference
[Qt3Support module]

The Q3TextBrowser class provides a rich text browser with hypertext navigation. More...

#include <Q3TextBrowser>

This class is part of the Qt 3 support library. It is provided to keep old source code working. We strongly advise against using it in new code. See Porting to Qt 4 for more information.

Inherits Q3TextEdit.

Properties

Public Functions

  • 51 public functions inherited from Q3TextEdit
  • 46 public functions inherited from Q3ScrollView
  • 4 public functions inherited from Q3Frame
  • 13 public functions inherited from QFrame
  • 190 public functions inherited from QWidget
  • 28 public functions inherited from QObject
  • 12 public functions inherited from QPaintDevice

Public Slots

Signals

Protected Functions

  • 6 protected functions inherited from Q3TextEdit
  • 17 protected functions inherited from Q3ScrollView
  • 5 protected functions inherited from Q3Frame
  • 39 protected functions inherited from QWidget
  • 7 protected functions inherited from QObject
  • 1 protected function inherited from QPaintDevice

Additional Inherited Members

  • 2 static public members inherited from QFrame
  • 4 static public members inherited from QWidget
  • 4 static public members inherited from QObject

Detailed Description

The Q3TextBrowser class provides a rich text browser with hypertext navigation.

This class extends Q3TextEdit (in read-only mode), adding some navigation functionality so that users can follow links in hypertext documents. The contents of Q3TextEdit is set with setText(), but Q3TextBrowser has an additional function, setSource(), which makes it possible to set the text to a named document. The name is looked up in the text view's mime source factory. If a document name ends with an anchor (for example, "#anchor"), the text browser automatically scrolls to that position (using scrollToAnchor()). When the user clicks on a hyperlink, the browser will call setSource() itself, with the link's href value as argument. You can track the current source by connetion to the sourceChanged() signal.

Q3TextBrowser provides backward() and forward() slots which you can use to implement Back and Forward buttons. The home() slot sets the text to the very first document displayed. The linkClicked() signal is emitted when the user clicks a link.

By using Q3TextEdit::setMimeSourceFactory() you can provide your own subclass of Q3MimeSourceFactory. This makes it possible to access data from anywhere, for example from a network or from a database. See Q3MimeSourceFactory::data() for details.

If you intend using the mime factory to read the data directly from the file system, you may have to specify the encoding for the file extension you are using. For example:

    mimeSourceFactory()->setExtensionType("qml", "text/utf8");

This is to ensure that the factory is able to resolve the document names.

Q3TextBrowser interprets the tags it processes in accordance with the default style sheet. Change the style sheet with setStyleSheet(); see QStyleSheet for details.

If you want to provide your users with editable rich text use Q3TextEdit. If you want a text browser without hypertext navigation use Q3TextEdit, and use Q3TextEdit::setReadOnly() to disable editing. If you just need to display a small piece of rich text use QSimpleRichText or QLabel.


Property Documentation

source : QString

This property holds the name of the displayed document.

This is a an empty string if no document is displayed or if the source is unknown.

Setting this property uses the mimeSourceFactory() to lookup the named document. It also checks for optional anchors and scrolls the document accordingly.

If the first tag in the document is <qt type=detail>, the document is displayed as a popup rather than as new document in the browser window itself. Otherwise, the document is displayed normally in the text browser with the text set to the contents of the named document with setText().

If you are using the filesystem access capabilities of the mime source factory, you must ensure that the factory knows about the encoding of specified files; otherwise no data will be available. The default factory handles a couple of common file extensions such as *.html and *.txt with reasonable defaults. See Q3MimeSourceFactory::data() for details.

Access functions:

  • QString source () const
  • virtual void setSource ( const QString & name )

Member Function Documentation

Q3TextBrowser::Q3TextBrowser ( QWidget * parent = 0, const char * name = 0 )

Constructs an empty Q3TextBrowser called name, with parent parent.

void Q3TextBrowser::anchorClicked ( const QString & name, const QString & link )   [signal]

This signal is emitted when the user clicks an anchor. The link is the value of the href i.e. the name of the target document. The name is the name of the anchor.

See also linkClicked().

void Q3TextBrowser::backward ()   [virtual slot]

Changes the document displayed to the previous document in the list of documents built by navigating links. Does nothing if there is no previous document.

See also forward() and backwardAvailable().

void Q3TextBrowser::backwardAvailable ( bool available )   [signal]

This signal is emitted when the availability of backward() changes. available is false when the user is at home(); otherwise it is true.

void Q3TextBrowser::forward ()   [virtual slot]

Changes the document displayed to the next document in the list of documents built by navigating links. Does nothing if there is no next document.

See also backward() and forwardAvailable().

void Q3TextBrowser::forwardAvailable ( bool available )   [signal]

This signal is emitted when the availability of forward() changes. available is true after the user navigates backward() and false when the user navigates or goes forward().

void Q3TextBrowser::highlighted ( const QString & link )   [signal]

This signal is emitted when the user has selected but not activated a link in the document. link is the value of the href i.e. the name of the target document.

void Q3TextBrowser::home ()   [virtual slot]

Changes the document displayed to be the first document the browser displayed.

void Q3TextBrowser::keyPressEvent ( QKeyEvent * e )   [virtual protected]

The event e is used to provide the following keyboard shortcuts:

KeypressAction
Alt+Left Arrowbackward()
Alt+Right Arrowforward()
Alt+Up Arrowhome()

Reimplemented from QWidget.

void Q3TextBrowser::linkClicked ( const QString & link )   [signal]

This signal is emitted when the user clicks a link. The link is the value of the href i.e. the name of the target document.

The link will be the absolute location of the document, based on the value of the anchor's href tag and the current context of the document.

See also anchorClicked().

void Q3TextBrowser::reload ()   [virtual slot]

Reloads the current set source.

void Q3TextBrowser::setText ( const QString & txt )   [slot]

This is an overloaded member function, provided for convenience.

Sets the text to txt.

void Q3TextBrowser::sourceChanged ( const QString & src )   [signal]

This signal is emitted when the mime source has changed, src being the new source.

Source changes happen both programmatically when calling setSource(), forward(), backword() or home() or when the user clicks on links or presses the equivalent key sequences.

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 9
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 4.1
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