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

QKeySequence Class Reference

The QKeySequence class encapsulates a key sequence as used by accelerators. More...

#include <qkeysequence.h>

Inherits Qt.

List of all member functions.

Public Members

Related Functions

  • QDataStream & operator<< ( QDataStream & s, const QKeySequence & keysequence )
  • QDataStream & operator>> ( QDataStream & s, QKeySequence & keysequence )

Detailed Description

The QKeySequence class encapsulates a key sequence as used by accelerators.

A key sequence consists of up to four keyboard codes, each optionally combined with modifiers, e.g. SHIFT, CTRL, ALT, META, or UNICODE_ACCEL. For example, CTRL + Key_P might be a sequence used as a shortcut for printing a document. The key codes are listed in qnamespace.h. As an alternative, use UNICODE_ACCEL with the unicode code point of the character. For example, UNICODE_ACCEL + 'A' gives the same key sequence as Key_A.

Key sequences can be constructed either from an integer key code, or from a human readable translatable string such as "Ctrl+X,Alt+Space". A key sequence can be cast to a QString to obtain a human readable translated version of the sequence. Translations are done in the "QAccel" context.

See also QAccel and Miscellaneous Classes.


Member Function Documentation

QKeySequence::QKeySequence ()

Constructs an empty key sequence.

QKeySequence::QKeySequence ( const QString & key )

Creates a key sequence from the string key. For example "Ctrl+O" gives CTRL+UNICODE_ACCEL+'O'. The strings "Ctrl", "Shift", "Alt" and "Meta" are recognized, as well as their translated equivalents in the "QAccel" context (using QObject::tr()).

Multiple key codes (up to four) may be entered by separating them with commas, e.g. "Alt+X,Ctrl+S,Q".

This contructor is typically used with tr(), so that accelerator keys can be replaced in translations:

        QPopupMenu *file = new QPopupMenu( this );
        file->insertItem( tr("&Open..."), this, SLOT(open()),
                          QKeySequence( tr("Ctrl+O", "File|Open") ) );
    

Note the "File|Open" translator comment. It is by no means necessary, but it provides some context for the human translator.

QKeySequence::QKeySequence ( int key )

Constructs a key sequence that has a single key.

The key codes are listed in qnamespace.h and can be combined with modifiers, e.g. with SHIFT, CTRL, ALT, META or UNICODE_ACCEL.

QKeySequence::QKeySequence ( int k1, int k2, int k3 = 0, int k4 = 0 )

Constructs a key sequence with up to 4 keys k1, k2, k3 and k4.

The key codes are listed in qnamespace.h and can be combined with modifiers, e.g. with SHIFT, CTRL, ALT, META or UNICODE_ACCEL.

QKeySequence::QKeySequence ( const QKeySequence & keysequence )

Copy constructor. Makes a copy of keysequence.

QKeySequence::~QKeySequence ()

Destroys the key sequence.

uint QKeySequence::count () const

Returns the number of keys in the key sequence. The maximum is 4.

bool QKeySequence::isEmpty () const

Returns TRUE if the key sequence is empty; otherwise returns FALSE.

Qt::SequenceMatch QKeySequence::matches ( const QKeySequence & seq ) const

Matches the sequence with seq. Returns Qt::Identical if successful, Qt::PartialMatch for matching but incomplete seq, and Qt::NoMatch if the sequences have nothing in common. Returns Qt::NoMatch if seq is shorter.

QKeySequence::operator QString () const

Creates an accelerator string for the key sequence. For instance CTRL+Key_O gives "Ctrl+O". If the key sequence has multiple key codes they are returned comma-separated, e.g. "Alt+X, Ctrl+Y, Z". The strings, "Ctrl", "Shift", etc. are translated (using QObject::tr()) in the "QAccel" scope. If the key sequence has no keys, QString::null is returned.

On Mac OS X, the string returned resembles the sequence that is shown in the menubar.

QKeySequence::operator int () const

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

For backward compatibility: returns the first keycode as integer. If the key sequence is empty, 0 is returned.

bool QKeySequence::operator!= ( const QKeySequence & keysequence ) const

Returns TRUE if keysequence is not equal to this key sequence; otherwise returns FALSE.

QKeySequence & QKeySequence::operator= ( const QKeySequence & keysequence )

Assignment operator. Assigns keysequence to this object.

bool QKeySequence::operator== ( const QKeySequence & keysequence ) const

Returns TRUE if keysequence is equal to this key sequence; otherwise returns FALSE.

int QKeySequence::operator[] ( uint index ) const

Returns a reference to the element at position index in the key sequence. This can only be used to read an element.

Related Functions

QDataStream & operator<< ( QDataStream & s, const QKeySequence & keysequence )

Writes the key sequence keysequence to the stream s.

See also Format of the QDataStream operators.

QDataStream & operator>> ( QDataStream & s, QKeySequence & keysequence )

Reads a key sequence from the stream s into the key sequence keysequence.

See also Format of the QDataStream operators.


This file is part of the Qt toolkit. Copyright © 1995-2005 Trolltech. All Rights Reserved.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année

Le Qt Developer Network au hasard

Logo

Utiliser QML et QtWebKit avec PySide

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 3.3
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