QAccel Class Reference


#include <qaccel.h>

Inherits QObject.

Public Members

Signals

Protected Members


Detailed Description

The QAccel class contains a number of accelerator items. An accelerator item consists of a keyboard code combined with modifiers (SHIFT, CTRL and ALT), for example CTRL + Key_P could be a shortcut for printing a document. The key codes are listed in qkeycode.h.

When pressed, an accelerator key sends out the signal activated() with a number that identifies this particular accelerator item. Accelerator items can also be individually connected, so that two different keys will activate two different slots (see connectItem()).

A QAccel object handles key events to its parent widget and all children of this parent widget.


Member Function Documentation

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

Creates a QAccel object with a parent widget and a name.

QAccel::~QAccel ()

Destroys the accelerator object.

void QAccel::clear ()

Removes all accelerator items.

bool QAccel::connectItem (int id, const QObject *receiver, const char *member)

Connects an accelerator item to a function in another object.

Arguments:

a->connectItem( 201, mainView, SLOT(quit()) );

int QAccel::count () const

Returns the number of accelerator items.

void QAccel::disable ()

Disables the accelerator. Individual keys cannot be enabled in this mode.

void QAccel::disableItem (int id)

Disables the accelerator items with the identifier id.

bool QAccel::disconnectItem (int id, const QObject *receiver, const char *member)

Disconnects an accelerator item from a function in another object.

See also: connectItem().

void QAccel::enable ()

Enables the accelerator. The accelerator is initially enabled. Individual keys can be enabled/disabled with the setItemEnabled(), enableItem() and disableItem() functions.

void QAccel::enableItem (int id)

Enables the accelerator items with the identifier id.

int QAccel::findKey (long key) const

Returns the identifier of the accelerator item with the key code key, or -1 if the item cannot be found.

void QAccel::insertItem (long key, int id=-1)

Inserts an accelerator item.

Arguments:

If id is negative, then the item will be assigned a unique identifier.

QAccel *a = new QAccel( mainView );     // mainView is a top level widget
a->insertItem( Key_P | CTRL, 200 );     // Ctrl+P to print document
a->insertItem( Key_X | ALT , 201 );     // Alt+X  to quit
a->insertItem( Key_D );                 // gets id 2
a->insertItem( Key_P | CTRL | SHIFT );  // gets id 3

bool QAccel::isDisabled () const

Returns TRUE if the accelerator is disabled.

bool QAccel::isItemDisabled (int id) const

Returns TRUE if the accelerator items with the identifier id is disabled. Returns FALSE if the item is enabled or cannot be found.

bool QAccel::isItemEnabled (int id) const

Returns TRUE if the accelerator items with the identifier id is enabled. Returns FALSE if the item is disabled or cannot be found.

long QAccel::key (int id)

Returns the key code of the accelerator item with the identifier id, or zero if the id cannot be found.

void QAccel::removeItem (int id)

Removes the accelerator item with the identifier id.

void QAccel::setItemEnabled (int id, bool enable)

Enables or disables an accelerator item.

Arguments:


This file is part of the Qt toolkit, copyright 1995 Troll Tech, all rights reserved.

It was generated from the following files:


Generated at 16:17, 1995/06/30 by the webmaster at Troll Tech