Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QQuickKeyNavigationAttached Class Reference

#include <qquickitem_p.h>

Inheritance diagram for QQuickKeyNavigationAttached:
Collaboration diagram for QQuickKeyNavigationAttached:

Public Types

enum  Priority { BeforeItem , AfterItem }

Signals

void leftChanged ()
void rightChanged ()
void upChanged ()
void downChanged ()
void tabChanged ()
void backtabChanged ()
void priorityChanged ()
Signals inherited from QObject
void destroyed (QObject *=nullptr)
 This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked.
void objectNameChanged (const QString &objectName, QPrivateSignal)
 This signal is emitted after the object's name has been changed.

Public Member Functions

 QQuickKeyNavigationAttached (QObject *=nullptr)
 \qmltype KeyNavigation \nativetype QQuickKeyNavigationAttached \inqmlmodule QtQuick
QQuickItemleft () const
void setLeft (QQuickItem *)
QQuickItemright () const
void setRight (QQuickItem *)
QQuickItemup () const
void setUp (QQuickItem *)
QQuickItemdown () const
void setDown (QQuickItem *)
QQuickItemtab () const
void setTab (QQuickItem *)
QQuickItembacktab () const
void setBacktab (QQuickItem *)
Priority priority () const
 \qmlattachedproperty enumeration QtQuick::KeyNavigation::priority
void setPriority (Priority)
Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 Constructs an object with parent object parent.
virtual ~QObject ()
 Destroys the object, deleting all its child objects.
virtual bool event (QEvent *event)
 This virtual function receives events to an object and should return true if the event e was recognized and processed.
virtual bool eventFilter (QObject *watched, QEvent *event)
 Filters events if this object has been installed as an event filter for the watched object.
QString objectName () const
Q_WEAK_OVERLOAD void setObjectName (const QString &name)
 Sets the object's name to name.
void setObjectName (QAnyStringView name)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
QBindable< QStringbindableObjectName ()
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false.
bool isWindowType () const
 Returns true if the object is a window; otherwise returns false.
bool isQuickItemType () const
 Returns true if the object is a QQuickItem; otherwise returns false.
bool isQmlObjectType () const
 Returns whether the object has been created by the QML engine or ownership has been explicitly set via QJSEngine::setObjectOwnership().
bool signalsBlocked () const noexcept
 Returns true if signals are blocked; otherwise returns false.
bool blockSignals (bool b) noexcept
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it).
QThreadthread () const
 Returns the thread in which the object lives.
bool moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL)
 Changes the thread affinity for this object and its children and returns true on success.
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds.
int startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer)
void killTimer (int id)
 Kills the timer with timer identifier, id.
void killTimer (Qt::TimerId id)
template<typename T>
findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object.
template<typename T>
QList< T > findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
template<typename T>
findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename T>
QList< T > findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
const QObjectListchildren () const
 Returns a list of child objects.
void setParent (QObject *parent)
 Makes the object a child of parent.
void installEventFilter (QObject *filterObj)
 Installs an event filter filterObj on this object.
void removeEventFilter (QObject *obj)
 Removes an event filter object obj from this object.
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
bool disconnect (const QObject *receiver, const char *member=nullptr) const
void dumpObjectTree () const
 Dumps a tree of children to the debug output.
void dumpObjectInfo () const
 Dumps information about signal connections, etc.
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value.
bool setProperty (const char *name, QVariant &&value)
QVariant property (const char *name) const
 Returns the value of the object's name property.
QList< QByteArraydynamicPropertyNames () const
QBindingStoragebindingStorage ()
const QBindingStoragebindingStorage () const
QObjectparent () const
 Returns a pointer to the parent object.
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false.
Public Member Functions inherited from QQuickItemKeyFilter
 QQuickItemKeyFilter (QQuickItem *=nullptr)
virtual ~QQuickItemKeyFilter ()
virtual void shortcutOverrideEvent (QKeyEvent *event)
virtual void componentComplete ()

Static Public Member Functions

static QQuickKeyNavigationAttachedqmlAttachedProperties (QObject *)
Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 \threadsafe
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
template<typename Func1, typename Func2>
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection)
template<typename Func1, typename Func2>
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot)
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 \threadsafe
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
static bool disconnect (const QMetaObject::Connection &)
 Disconnect a connection.
template<typename Func1, typename Func2>
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
template<typename Func1>
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)

Properties

QQuickItemleft
QQuickItemright
QQuickItemup
QQuickItemdown
QQuickItemtab
QQuickItembacktab
Priority priority
Properties inherited from QObject
QString objectName
 the name of this object

Private Member Functions

void keyPressed (QKeyEvent *event, bool post) override
void keyReleased (QKeyEvent *event, bool post) override

Additional Inherited Members

Public Slots inherited from QObject
void deleteLater ()
 \threadsafe
Public Attributes inherited from QQuickItemKeyFilter
bool m_processPost
Protected Member Functions inherited from QObject
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr.
int senderSignalIndex () const
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal.
bool isSignalConnected (const QMetaMethod &signal) const
virtual void timerEvent (QTimerEvent *event)
 This event handler can be reimplemented in a subclass to receive timer events for the object.
virtual void childEvent (QChildEvent *event)
 This event handler can be reimplemented in a subclass to receive child events.
virtual void customEvent (QEvent *event)
 This event handler can be reimplemented in a subclass to receive custom events.
virtual void connectNotify (const QMetaMethod &signal)
virtual void disconnectNotify (const QMetaMethod &signal)
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr

Detailed Description

Definition at line 832 of file qquickitem_p.h.

Member Enumeration Documentation

◆ Priority

Enumerator
BeforeItem 
AfterItem 

Definition at line 866 of file qquickitem_p.h.

Constructor & Destructor Documentation

◆ QQuickKeyNavigationAttached()

QQuickKeyNavigationAttached::QQuickKeyNavigationAttached ( QObject * parent = nullptr)

\qmltype KeyNavigation \nativetype QQuickKeyNavigationAttached \inqmlmodule QtQuick

Supports key navigation by arrow keys.

Key-based user interfaces commonly allow the use of arrow keys to navigate between focusable items. The KeyNavigation attaching type enables this behavior by providing a convenient way to specify the item that should gain focus when an arrow or tab key is pressed.

The following example provides key navigation for a 2x2 grid of items:

import QtQuick
Grid {
width: 100; height: 100
columns: 2
Rectangle {
id: topLeft
width: 50; height: 50
color: focus ? "red" : "lightgray"
focus: true
KeyNavigation.right: topRight
KeyNavigation.down: bottomLeft
}
Rectangle {
id: topRight
width: 50; height: 50
color: focus ? "red" : "lightgray"
KeyNavigation.left: topLeft
KeyNavigation.down: bottomRight
}
Rectangle {
id: bottomLeft
width: 50; height: 50
color: focus ? "red" : "lightgray"
KeyNavigation.right: bottomRight
KeyNavigation.up: topLeft
}
Rectangle {
id: bottomRight
width: 50; height: 50
color: focus ? "red" : "lightgray"
KeyNavigation.left: bottomLeft
KeyNavigation.up: topRight
}
}

The top-left item initially receives focus by setting \l {Item::}{focus} to true. When an arrow key is pressed, the focus will move to the appropriate item, as defined by the value that has been set for the KeyNavigation \l left, \l right, \l up or \l down properties.

Note that if a KeyNavigation attaching type receives the key press and release events for a requested arrow or tab key, the event is accepted and does not propagate any further.

By default, KeyNavigation receives key events after the item to which it is attached. If the item accepts the key event, the KeyNavigation attaching type will not receive an event for that key. Setting the \l priority property to KeyNavigation.BeforeItem allows the event to be used for key navigation before the item, rather than after.

If the item to which the focus is switching is not enabled or visible, an attempt will be made to skip this item and focus on the next. This is possible if there are a chain of items with the same KeyNavigation handler. If multiple items in a row are not enabled or visible, they will also be skipped.

KeyNavigation will implicitly set the other direction to return focus to this item. So if you set \l left to another item, \l right will be set on that item's KeyNavigation to set focus back to this item. However, if that item's KeyNavigation has had right explicitly set then no change will occur. This means that the example above could achieve the same behavior without specifying KeyNavigation.right or KeyNavigation.down for any of the items.

See also
{Keys}{Keys attached property}

\qmlattachedproperty Item QtQuick::KeyNavigation::left

This property holds the item to assign focus to when the left cursor key is pressed.

\qmlattachedproperty Item QtQuick::KeyNavigation::right

This property holds the item to assign focus to when the right cursor key is pressed.

\qmlattachedproperty Item QtQuick::KeyNavigation::up

This property holds the item to assign focus to when the up cursor key is pressed.

\qmlattachedproperty Item QtQuick::KeyNavigation::down

This property holds the item to assign focus to when the down cursor key is pressed.

\qmlattachedproperty Item QtQuick::KeyNavigation::tab

This property holds the item to assign focus to when the Tab key is pressed.

\qmlattachedproperty Item QtQuick::KeyNavigation::backtab

This property holds the item to assign focus to when the Shift+Tab key combination (Backtab) is pressed.

Definition at line 434 of file qquickitem.cpp.

Member Function Documentation

◆ backtab()

QQuickItem * QQuickKeyNavigationAttached::backtab ( ) const

Definition at line 557 of file qquickitem.cpp.

◆ backtabChanged

void QQuickKeyNavigationAttached::backtabChanged ( )
signal

◆ down()

QQuickItem * QQuickKeyNavigationAttached::down ( ) const

Definition at line 513 of file qquickitem.cpp.

◆ downChanged

void QQuickKeyNavigationAttached::downChanged ( )
signal

◆ keyPressed()

void QQuickKeyNavigationAttached::keyPressed ( QKeyEvent * event,
bool post )
overrideprivatevirtual

Reimplemented from QQuickItemKeyFilter.

Definition at line 606 of file qquickitem.cpp.

◆ keyReleased()

void QQuickKeyNavigationAttached::keyReleased ( QKeyEvent * event,
bool post )
overrideprivatevirtual

Reimplemented from QQuickItemKeyFilter.

Definition at line 669 of file qquickitem.cpp.

◆ left()

QQuickItem * QQuickKeyNavigationAttached::left ( ) const

Definition at line 447 of file qquickitem.cpp.

◆ leftChanged

void QQuickKeyNavigationAttached::leftChanged ( )
signal

◆ priority()

QQuickKeyNavigationAttached::Priority QQuickKeyNavigationAttached::priority ( ) const

\qmlattachedproperty enumeration QtQuick::KeyNavigation::priority

This property determines whether the keys are processed before or after the attached item's own key handling.

\value KeyNavigation.BeforeItem process the key events before normal item key processing. If the event is used for key navigation, it will be accepted and will not be passed on to the item. \value KeyNavigation.AfterItem (default) process the key events after normal item key handling. If the item accepts the key event it will not be handled by the KeyNavigation attached property handler.

Definition at line 592 of file qquickitem.cpp.

◆ priorityChanged

void QQuickKeyNavigationAttached::priorityChanged ( )
signal

◆ qmlAttachedProperties()

QQuickKeyNavigationAttached * QQuickKeyNavigationAttached::qmlAttachedProperties ( QObject * obj)
static

Definition at line 442 of file qquickitem.cpp.

◆ right()

QQuickItem * QQuickKeyNavigationAttached::right ( ) const

Definition at line 469 of file qquickitem.cpp.

◆ rightChanged

void QQuickKeyNavigationAttached::rightChanged ( )
signal

◆ setBacktab()

void QQuickKeyNavigationAttached::setBacktab ( QQuickItem * i)

Definition at line 563 of file qquickitem.cpp.

◆ setDown()

void QQuickKeyNavigationAttached::setDown ( QQuickItem * i)

Definition at line 519 of file qquickitem.cpp.

◆ setLeft()

void QQuickKeyNavigationAttached::setLeft ( QQuickItem * i)

Definition at line 453 of file qquickitem.cpp.

◆ setPriority()

void QQuickKeyNavigationAttached::setPriority ( Priority order)

Definition at line 597 of file qquickitem.cpp.

◆ setRight()

void QQuickKeyNavigationAttached::setRight ( QQuickItem * i)

Definition at line 475 of file qquickitem.cpp.

◆ setTab()

void QQuickKeyNavigationAttached::setTab ( QQuickItem * i)

Definition at line 541 of file qquickitem.cpp.

◆ setUp()

void QQuickKeyNavigationAttached::setUp ( QQuickItem * i)

Definition at line 497 of file qquickitem.cpp.

◆ tab()

QQuickItem * QQuickKeyNavigationAttached::tab ( ) const

Definition at line 535 of file qquickitem.cpp.

◆ tabChanged

void QQuickKeyNavigationAttached::tabChanged ( )
signal

◆ up()

QQuickItem * QQuickKeyNavigationAttached::up ( ) const

Definition at line 491 of file qquickitem.cpp.

◆ upChanged

void QQuickKeyNavigationAttached::upChanged ( )
signal

Property Documentation

◆ backtab

QQuickItem * QQuickKeyNavigationAttached::backtab
readwrite

Definition at line 842 of file qquickitem_p.h.

◆ down

QQuickItem * QQuickKeyNavigationAttached::down
readwrite

Definition at line 840 of file qquickitem_p.h.

◆ left

QQuickItem * QQuickKeyNavigationAttached::left
readwrite

Definition at line 837 of file qquickitem_p.h.

Referenced by testing.tools.safetynet_image.ImageLocations::Left().

◆ priority

Priority QQuickKeyNavigationAttached::priority
readwrite

Definition at line 843 of file qquickitem_p.h.

◆ right

QQuickItem * QQuickKeyNavigationAttached::right
readwrite

Definition at line 838 of file qquickitem_p.h.

Referenced by testing.tools.safetynet_image.ImageLocations::Right().

◆ tab

QQuickItem * QQuickKeyNavigationAttached::tab
readwrite

Definition at line 841 of file qquickitem_p.h.

◆ up

QQuickItem * QQuickKeyNavigationAttached::up
readwrite

Definition at line 839 of file qquickitem_p.h.


The documentation for this class was generated from the following files: