返回介绍

QKeySequence Class

发布于 2019-10-04 15:00:54 字数 4793 浏览 1592 评论 0 收藏 0

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

#include <qkeysequence.h>

Inherits Qt.

List of all member functions.

Public Members

  • QKeySequence ()
  • QKeySequence ( constQString&key )
  • QKeySequence ( intkey )
  • operator QString () const
  • operator int () const
  • QKeySequence ( constQKeySequence&keysequence )
  • QKeySequence & operator= ( constQKeySequence&keysequence )
  • ~QKeySequence ()
  • bool operator== ( constQKeySequence&keysequence ) const
  • bool operator!= ( constQKeySequence&keysequence ) const

Related Functions

  • QDataStream & operator<< ( QDataStream&s, constQKeySequence&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 a keyboard code, optionally combined with modifiers, e.g. SHIFT, CTRL, ALT 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. 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 ( constQString&key )

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

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 ( intkey )

Constructs a key sequence from the keycode key.

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

QKeySequence::QKeySequence ( constQKeySequence&keysequence )

Copy constructor. Makes a copy of keysequence.

QKeySequence::~QKeySequence ()

Destroys the key sequence.

QKeySequence::operator QString () const

Creates an accelerator string for the key sequence. For example, CTRL+Key_O gives "Ctrl+O". The strings, "Ctrl", "Shift", etc. are translated (using QObject::tr()) in the "QAccel" context.

QKeySequence::operator int () const

For backward compatibility: returns the keycode as an integer.

If QKeySequence ever supports more than one keycode, this function will return the first one.

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

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

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

Assignment operator. Assigns keysequence to this object.

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

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

Related Functions

QDataStream& operator<< ( QDataStream&s, constQKeySequence&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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文