Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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 \instantiates 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 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 769 of file qquickitem_p.h.

Member Enumeration Documentation

◆ Priority

Enumerator
BeforeItem 
AfterItem 

Definition at line 803 of file qquickitem_p.h.

Constructor & Destructor Documentation

◆ QQuickKeyNavigationAttached()

QQuickKeyNavigationAttached::QQuickKeyNavigationAttached ( QObject * parent = nullptr)

\qmltype KeyNavigation \instantiates 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 attached property 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 attached property 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 attached property 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 430 of file qquickitem.cpp.

References QQuickItemKeyFilter::m_processPost.

Referenced by qmlAttachedProperties().

+ Here is the caller graph for this function:

Member Function Documentation

◆ backtab()

QQuickItem * QQuickKeyNavigationAttached::backtab ( ) const

Definition at line 553 of file qquickitem.cpp.

References d.

◆ backtabChanged

void QQuickKeyNavigationAttached::backtabChanged ( )
signal

Referenced by setBacktab().

+ Here is the caller graph for this function:

◆ down()

QQuickItem * QQuickKeyNavigationAttached::down ( ) const

Definition at line 509 of file qquickitem.cpp.

References d.

◆ downChanged

void QQuickKeyNavigationAttached::downChanged ( )
signal

Referenced by setDown().

+ Here is the caller graph for this function:

◆ keyPressed()

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

Reimplemented from QQuickItemKeyFilter.

Definition at line 602 of file qquickitem.cpp.

References Qt::BacktabFocusReason, d, QQuickItemPrivate::get(), Qt::Key_Backtab, Qt::Key_Down, Qt::Key_Left, Qt::Key_Right, Qt::Key_Tab, Qt::Key_Up, QQuickItemKeyFilter::keyPressed(), QQuickItemKeyFilter::m_processPost, QObject::parent(), post(), and Qt::TabFocusReason.

+ Here is the call graph for this function:

◆ keyReleased()

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

Reimplemented from QQuickItemKeyFilter.

Definition at line 665 of file qquickitem.cpp.

References d, QQuickItemPrivate::get(), Qt::Key_Backtab, Qt::Key_Down, Qt::Key_Left, Qt::Key_Right, Qt::Key_Tab, Qt::Key_Up, QQuickItemKeyFilter::keyReleased(), QQuickItemKeyFilter::m_processPost, QObject::parent(), and post().

+ Here is the call graph for this function:

◆ left()

QQuickItem * QQuickKeyNavigationAttached::left ( ) const

Definition at line 443 of file qquickitem.cpp.

References d.

◆ leftChanged

void QQuickKeyNavigationAttached::leftChanged ( )
signal

Referenced by setLeft().

+ Here is the caller graph for this function:

◆ 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 588 of file qquickitem.cpp.

References AfterItem, BeforeItem, and QQuickItemKeyFilter::m_processPost.

◆ priorityChanged

void QQuickKeyNavigationAttached::priorityChanged ( )
signal

Referenced by setPriority().

+ Here is the caller graph for this function:

◆ qmlAttachedProperties()

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

Definition at line 438 of file qquickitem.cpp.

References QQuickKeyNavigationAttached().

Referenced by QQuickFileDialogImpl::componentComplete(), and QQuickFolderDialogImpl::componentComplete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ right()

QQuickItem * QQuickKeyNavigationAttached::right ( ) const

Definition at line 465 of file qquickitem.cpp.

References d.

◆ rightChanged

void QQuickKeyNavigationAttached::rightChanged ( )
signal

Referenced by setRight().

+ Here is the caller graph for this function:

◆ setBacktab()

void QQuickKeyNavigationAttached::setBacktab ( QQuickItem * i)

Definition at line 559 of file qquickitem.cpp.

References backtabChanged(), d, emit, i, other(), QObject::parent(), and qobject_cast< QQuickItem * >().

+ Here is the call graph for this function:

◆ setDown()

void QQuickKeyNavigationAttached::setDown ( QQuickItem * i)

Definition at line 515 of file qquickitem.cpp.

References d, downChanged(), emit, i, other(), QObject::parent(), and qobject_cast< QQuickItem * >().

+ Here is the call graph for this function:

◆ setLeft()

void QQuickKeyNavigationAttached::setLeft ( QQuickItem * i)

Definition at line 449 of file qquickitem.cpp.

References d, emit, i, leftChanged(), other(), QObject::parent(), and qobject_cast< QQuickItem * >().

+ Here is the call graph for this function:

◆ setPriority()

void QQuickKeyNavigationAttached::setPriority ( Priority order)

Definition at line 593 of file qquickitem.cpp.

References AfterItem, emit, QQuickItemKeyFilter::m_processPost, and priorityChanged().

+ Here is the call graph for this function:

◆ setRight()

void QQuickKeyNavigationAttached::setRight ( QQuickItem * i)

Definition at line 471 of file qquickitem.cpp.

References d, emit, i, other(), QObject::parent(), qobject_cast< QQuickItem * >(), and rightChanged().

+ Here is the call graph for this function:

◆ setTab()

void QQuickKeyNavigationAttached::setTab ( QQuickItem * i)

Definition at line 537 of file qquickitem.cpp.

References d, emit, i, other(), QObject::parent(), qobject_cast< QQuickItem * >(), and tabChanged().

+ Here is the call graph for this function:

◆ setUp()

void QQuickKeyNavigationAttached::setUp ( QQuickItem * i)

Definition at line 493 of file qquickitem.cpp.

References d, emit, i, other(), QObject::parent(), qobject_cast< QQuickItem * >(), and upChanged().

+ Here is the call graph for this function:

◆ tab()

QQuickItem * QQuickKeyNavigationAttached::tab ( ) const

Definition at line 531 of file qquickitem.cpp.

References d.

◆ tabChanged

void QQuickKeyNavigationAttached::tabChanged ( )
signal

Referenced by setTab().

+ Here is the caller graph for this function:

◆ up()

QQuickItem * QQuickKeyNavigationAttached::up ( ) const

Definition at line 487 of file qquickitem.cpp.

References d.

◆ upChanged

void QQuickKeyNavigationAttached::upChanged ( )
signal

Referenced by setUp().

+ Here is the caller graph for this function:

Property Documentation

◆ backtab

QQuickItem * QQuickKeyNavigationAttached::backtab
readwrite

Definition at line 779 of file qquickitem_p.h.

◆ down

QQuickItem * QQuickKeyNavigationAttached::down
readwrite

Definition at line 777 of file qquickitem_p.h.

◆ left

QQuickItem * QQuickKeyNavigationAttached::left
readwrite

Definition at line 774 of file qquickitem_p.h.

◆ priority

Priority QQuickKeyNavigationAttached::priority
readwrite

Definition at line 780 of file qquickitem_p.h.

◆ right

QQuickItem * QQuickKeyNavigationAttached::right
readwrite

Definition at line 775 of file qquickitem_p.h.

◆ tab

QQuickItem * QQuickKeyNavigationAttached::tab
readwrite

Definition at line 778 of file qquickitem_p.h.

◆ up

QQuickItem * QQuickKeyNavigationAttached::up
readwrite

Definition at line 776 of file qquickitem_p.h.


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