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  · 

Using the Editor

Qt Creator's code editor is designed to aid you in creating, editing and navigating code. Qt Creator's code editor is fully equipped with syntax checking, code completion, context sensitive help and in-line error indicators while you are typing.

Using the Editor Toolbar

The editor toolbar is located at the top of the editor view. The editor toolbar is context sensitive and shows items relevant to the file currently open in the editor.

Use the toolbar to navigate between open files and symbols in use:

  • To browse forward or backward through your location history, click and .
  • To go to any open file, select it from the Open files drop-down menu.
  • To jump to any symbol used in the current file, select it from the Symbols drop-down menu.

When you create or edit forms in a .ui file, the toolbar contains Qt Designer specific tools.

Splitting the Editor View

Split the editor view when you want to work on and view multiple files on the same screen.

You can split the editor view in the following ways:

  • To split the editor view into a top and bottom view, select Window > Split or press Ctrl+E, 2.

    Split command creates views below the currently active editor view.

  • To split the editor view into adjacent views, select Window > Split Side by Side or press Ctrl+E, 3.

    Side by side split command creates views to the right of the currently active editor view.

To move between split views, select Window > Go to Next Split or press Ctrl+E, O.

To remove a split view, place the cursor within the view you want to remove and select Window > Remove Current Split or press Ctrl+E, 0. To remove all but the currently selected split view, select Window > Remove All Splits or press Ctrl+E, 1.

Highlighting and Folding Blocks

Use block highlighting to visually separate parts of the code that belong together. For example, when you place the cursor within the braces, the code enclosed in braces is highlighted.

To enable block highlighting, select Tools > Options... > Text Editor > Display > Highlight blocks.

Use the folding markers to collapse and expand blocks of code within braces. Click the folding marker to collapse or expand a block. In the figure above, the folding markers are located between the line number and the text pane.

To show the folding markers, select Tools > Options... > Text Editor > Display > Display folding markers. This option is enabled by default.

When the cursor is on a brace, the matching brace is animated by default. To turn off the animation and just highlight the block and the braces, select Tools > Options... > Text Editor > Display and deselect Animate matching parentheses.

Checking Code Syntax

As you write code Qt Creator checks code syntax. When Qt Creator spots a syntax error in your code it underlines it and shows error details when you move the mouse pointer over the error.

  • Syntax errors are underlined in red.

    In the following figure, a semicolon is missing at the end of the line.

  • Semantic errors and warnings are underlined in olive.

    In the following figure, the type is unknown.

Completing Code

Qt Creator understands the code as code, not just as plain text. This allows it to help you to write well formatted code and to anticipate what you are going to write and complete the code. As you write code, Qt Creator provides a list of context-sensitive suggestions to the statement currently under your cursor.

To open the list of suggestions at any time, press Ctrl+Space. If only one option is available, Qt Creator inserts it automatically.

When completion is invoked manually, Qt Creator completes the common prefix of the list of suggestions. This is especially useful for classes with several similarly named members. To disable this functionality, uncheck Autocomplete common prefix in the code completion preferences. Select Tools > Options... > Text Editor > Completion.

By default, code completion considers only the first letter case-sensitive. To apply full or no case-sensitivity, select the option in the Case-sensitivity field.

The following table lists available types for code completion and icon used for each.

IconDescription

A class

An enum

An enumerator (value of an enum)

A function

A private function

A protected function

A variable

A private variable

A protected variable

A signal

A slot

A private slot

A protected slot

A keyword

A macro

A namespace

Using Bookmarks

To insert or delete a bookmark right-click the line number and select Toggle Bookmark or press Ctrl+M.

To go to previous bookmark in the current session, press Ctrl+,.

To go to next bookmark in the current session, press Ctrl+..

Moving to Symbol Definition or Declaration

In Qt Creator you can move directly to the definition or the declaration of a symbol by holding the Ctrl and clicking the symbol.

To enable this moving function, in Tools > Options... > Text Editor > Behavior select Enable mouse navigation.

Using Update Code Model

To refresh the internal information in Qt Creator pertaining to your code, select Tools > C++ > Update Code Model.

Note: In Qt Creator indexing updates the code automatically. Use Update Code Model only as an emergency command.

X

rc="scripts/functions.js" type="text/javascript">
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 64
  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. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Developer Network au hasard

Logo

Comment fermer une application

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 qtcreator-2.0
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