|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QShortcut
public class QShortcut
The For applications that use menus, it may be more convenient to use the convenience functions provided in the The simplest way to create a shortcut for a particular widget is to construct the shortcut with a key sequence. For example: QShortcut
class is used to create keyboard shortcuts. The QShortcut
class provides a way of connecting keyboard shortcuts to Qt's signals and slots mechanism, so that objects can be informed when a shortcut is executed. The shortcut can be set up to contain all the key presses necessary to describe a keyboard shortcut, including the states of modifier keys such as Shift, Ctrl, and Alt. On certain widgets, using '&' in front of a character will automatically create a mnemonic (a shortcut) for that character, e.g. "E&xit" will create the shortcut Alt+X (use '&&' to display an actual ampersand). The widget might consume and perform an action on a given shortcut. On X11 the ampersand will not be shown and the character will be underlined. On Windows, shortcuts are normally not displayed until the user presses the Alt key, but this is a setting the user can change. On Mac, shortcuts are disabled by default. Call qt_set_sequence_auto_mnemonic() to enable them. However, because mnemonic shortcuts do not fit in with Aqua's guidelines, Qt will not show the shortcut character underlined. QMenu
class to assign keyboard shortcuts to menu items as they are created. Alternatively, shortcuts may be associated with other types of actions in the QAction
class.
shortcut = new QShortcut(new QKeySequence(tr("Ctrl+O", "File|Open")),
parent);
When the user types the key sequence
for a given shortcut, the shortcut's activated()
signal is emitted. (In the case of ambiguity, the activatedAmbiguously()
signal is emitted.) A shortcut is "listened for" by Qt's event loop when the shortcut's parent widget is receiving events.
A shortcut's key sequence can be set with setKey()
and retrieved with key()
. A shortcut can be enabled or disabled with setEnabled()
, and can have "What's This?" help text set with setWhatsThis()
.
QShortcutEvent
, QKeySequence
, and QAction
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal |
Field Summary | |
---|---|
QSignalEmitter.Signal0 |
activated
This signal is emitted when the user types the shortcut's key sequence. |
QSignalEmitter.Signal0 |
activatedAmbiguously
This signal is emitted when the user types the shortcut's key sequence. |
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
currentSender |
Constructor Summary | |
---|---|
QShortcut(QKeySequence key,
QWidget parent)
This is an overloaded constructor provided for convenience. |
|
QShortcut(QKeySequence key,
QWidget parent,
Qt.ShortcutContext context)
Constructs a QShortcut object for the parent widget. |
|
QShortcut(QWidget parent)
Constructs a QShortcut object for the parent widget. |
Method Summary | |
---|---|
boolean |
autoRepeat()
This property holds whether the shortcut can auto repeat. |
Qt.ShortcutContext |
context()
This property holds the context in which the shortcut is valid. |
int |
id()
Returns the shortcut's ID. |
boolean |
isEnabled()
This property holds whether the shortcut is enabled. |
QKeySequence |
key()
This property holds the shortcut's key sequence. |
QWidget |
parentWidget()
Returns the shortcut's parent widget. |
void |
setAutoRepeat(boolean on)
This property holds whether the shortcut can auto repeat. |
void |
setContext(Qt.ShortcutContext context)
This property holds the context in which the shortcut is valid. |
void |
setEnabled(boolean enable)
This property holds whether the shortcut is enabled. |
void |
setKey(QKeySequence key)
This property holds the shortcut's key sequence. |
void |
setWhatsThis(java.lang.String text)
This property holds the shortcut's "What's This?" help text. |
java.lang.String |
whatsThis()
This property holds the shortcut's "What's This?" help text. |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
__qt_signalInitialization |
Methods inherited from class java.lang.Object |
---|
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Field Detail |
---|
public final QSignalEmitter.Signal0 activated
activatedAmbiguously()
.
public final QSignalEmitter.Signal0 activatedAmbiguously
activatedAmbiguously()
.
Constructor Detail |
---|
public QShortcut(QWidget parent)
QShortcut
object for the parent widget. Since no shortcut key sequence is specified, the shortcut will not emit any signals. setKey()
.
public QShortcut(QKeySequence key, QWidget parent)
public QShortcut(QKeySequence key, QWidget parent, Qt.ShortcutContext context)
QShortcut
object for the parent widget. The shortcut operates on its parent, listening for QShortcutEvent
s that match the key sequence. Depending on the ambiguity of the event, the shortcut will call the member function, or the ambiguousMember function, if the key press was in the shortcut's context.
Method Detail |
---|
public final boolean autoRepeat()
public final Qt.ShortcutContext context()
Qt::WindowShortcut
, which allows the shortcut to trigger if the parent (the widget containing the shortcut) is a subwidget of the active top-level window. By default, this property is set to Qt::WindowShortcut
.
public final int id()
QShortcutEvent::shortcutId()
.
public final boolean isEnabled()
activated()
or activatedAmbiguously()
signal when a QShortcutEvent
occurs that matches the shortcut's key()
sequence. If the application is in WhatsThis mode the shortcut will not emit the signals, but will show the "What's This?" text instead.
By default, this property is true.
whatsThis
.
public final QKeySequence key()
shortcut.setKey(new QKeySequence(0)); // no signal emitted shortcut.setKey(new QKeySequence()); // no signal emitted shortcut.setKey(new QKeySequence(0x3b1)); // Greek letter alpha shortcut.setKey(new QKeySequence(Qt.Key.Key_D.value())); // 'd', e.g. to delete shortcut.setKey(new QKeySequence('q')); // 'q', e.g. to quit shortcut.setKey(new QKeySequence(Qt.KeyboardModifier.AltModifier.value() + Qt.Key.Key_P.value())); // Ctrl+P, e.g. to print document shortcut.setKey(new QKeySequence("Ctrl+P")); // Ctrl+P, e.g. to print documentBy default, this property contains an empty key sequence.
public final QWidget parentWidget()
public final void setAutoRepeat(boolean on)
public final void setContext(Qt.ShortcutContext context)
Qt::WindowShortcut
, which allows the shortcut to trigger if the parent (the widget containing the shortcut) is a subwidget of the active top-level window. By default, this property is set to Qt::WindowShortcut
.
public final void setEnabled(boolean enable)
activated()
or activatedAmbiguously()
signal when a QShortcutEvent
occurs that matches the shortcut's key()
sequence. If the application is in WhatsThis mode the shortcut will not emit the signals, but will show the "What's This?" text instead.
By default, this property is true.
whatsThis
.
public final void setKey(QKeySequence key)
shortcut.setKey(new QKeySequence(0)); // no signal emitted shortcut.setKey(new QKeySequence()); // no signal emitted shortcut.setKey(new QKeySequence(0x3b1)); // Greek letter alpha shortcut.setKey(new QKeySequence(Qt.Key.Key_D.value())); // 'd', e.g. to delete shortcut.setKey(new QKeySequence('q')); // 'q', e.g. to quit shortcut.setKey(new QKeySequence(Qt.KeyboardModifier.AltModifier.value() + Qt.Key.Key_P.value())); // Ctrl+P, e.g. to print document shortcut.setKey(new QKeySequence("Ctrl+P")); // Ctrl+P, e.g. to print documentBy default, this property contains an empty key sequence.
public final void setWhatsThis(java.lang.String text)
key()
sequence. To set "What's This?" help on a menu item (with or without a shortcut key), set the help on the item's action.
By default, this property contains an empty string.
QWhatsThis::inWhatsThisMode()
, and QAction::setWhatsThis()
.
public final java.lang.String whatsThis()
key()
sequence. To set "What's This?" help on a menu item (with or without a shortcut key), set the help on the item's action.
By default, this property contains an empty string.
QWhatsThis::inWhatsThisMode()
, and QAction::setWhatsThis()
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |