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  · 

QML KeyEvent Element

The KeyEvent object provides information about a key event. More...

This element was introduced in Qt 4.7.

Properties

Detailed Description

For example, the following changes the Item's state property when the Enter key is pressed:

 Item {
     focus: true
     Keys.onPressed: { if (event.key == Qt.Key_Enter) state = 'ShowDetails'; }
 }

Property Documentation

accepted : bool

Setting accepted to true prevents the key event from being propagated to the item's parent.

Generally, if the item acts on the key event then it should be accepted so that ancestor items do not also respond to the same event.


read-onlycount : int

This property holds the number of keys involved in this event. If KeyEvent::text is not empty, this is simply the length of the string.


read-onlyisAutoRepeat : bool

This property holds whether this event comes from an auto-repeating key.


read-onlykey : int

This property holds the code of the key that was pressed or released.

See Qt.Key for the list of keyboard codes. These codes are independent of the underlying window system. Note that this function does not distinguish between capital and non-capital letters, use the text() function (returning the Unicode text the key generated) for this purpose.

A value of either 0 or Qt.Key_Unknown means that the event is not the result of a known key; for example, it may be the result of a compose sequence, a keyboard macro, or due to key event compression.


read-onlymodifiers : int

This property holds the keyboard modifier flags that existed immediately before the event occurred.

It contains a bitwise combination of:

  • Qt.NoModifier - No modifier key is pressed.
  • Qt.ShiftModifier - A Shift key on the keyboard is pressed.
  • Qt.ControlModifier - A Ctrl key on the keyboard is pressed.
  • Qt.AltModifier - An Alt key on the keyboard is pressed.
  • Qt.MetaModifier - A Meta key on the keyboard is pressed.
  • Qt.KeypadModifier - A keypad button is pressed.

For example, to react to a Shift key + Enter key combination:

 Item {
     focus: true
     Keys.onPressed: {
         if ((event.key == Qt.Key_Enter) && (event.modifiers & Qt.ShiftModifier))
             doSomething();
     }
 }

read-onlytext : string

This property holds the Unicode text that the key generated. The text returned can be an empty string in cases where modifier keys, such as Shift, Control, Alt, and Meta, are being pressed or released. In such cases key will contain a valid value


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.8
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