QSignalTransition Class▲
-
Header: QSignalTransition
-
CMake:
find_package(Qt6 REQUIRED COMPONENTS StateMachine)
target_link_libraries(mytarget PRIVATE Qt6::StateMachine)
-
qmake: QT += statemachine
-
Inherits: QAbstractTransition
-
Inherited By:
-
Group: QSignalTransition is part of statemachine
Detailed Description▲
Typically you would use the overload of QState::addTransition() that takes a sender and signal as arguments, rather than creating QSignalTransition objects directly. QSignalTransition is part of Qt State Machine Framework.
You can subclass QSignalTransition and reimplement eventTest() to make a signal transition conditional; the event object passed to eventTest() will be a QStateMachine::SignalEvent object. Example:
class
CheckedTransition : public
QSignalTransition
{
public
:
CheckedTransition(QCheckBox *
check)
:
QSignalTransition(check, SIGNAL(stateChanged(int
))) {}
protected
:
bool
eventTest(QEvent *
e) {
if
(!
QSignalTransition::
eventTest(e))
return
false
;
QStateMachine::
SignalEvent *
se =
static_cast
&
lt;QStateMachine::
SignalEvent*&
gt;(e);
return
(se-&
gt;arguments().at(0
).toInt() ==
Qt::
Checked);
}
}
;
...
QCheckBox *
check =
new
QCheckBox();
check-&
gt;setTristate(true
);
QState *
s1 =
new
QState();
QState *
s2 =
new
QState();
CheckedTransition *
t1 =
new
CheckedTransition(check);
t1-&
gt;setTargetState(s2);
s1-&
gt;addTransition(t1);
Property Documentation▲
[bindable] senderObject : const QObject*▲
This property supports QProperty bindings.
This property holds the sender object that this signal transition is associated with
[bindable] signal : QByteArray▲
This property supports QProperty bindings.
This property holds the signal that this signal transition is associated with
Member Function Documentation▲
QSignalTransition::QSignalTransition(QState *sourceState = nullptr)▲
Constructs a new signal transition with the given sourceState.
QSignalTransition::QSignalTransition(const QObject *sender, const char *signal, QState *sourceState = nullptr)▲
Constructs a new signal transition associated with the given signal of the given sender, and with the given sourceState.
[since 5.7] QSignalTransition::QSignalTransition(const QObject *sender, PointerToMemberFunction signal, QState *sourceState = nullptr)▲
This is an overloaded function.
Constructs a new signal transition associated with the given signal of the given sender object and with the given sourceState. This constructor is enabled if the compiler supports delegating constructors, as indicated by the presence of the macro Q_COMPILER_DELEGATING_CONSTRUCTORS.
This function was introduced in Qt 5.7.
[virtual] QSignalTransition::~QSignalTransition()▲
Destroys this signal transition.
[override virtual protected] bool QSignalTransition::event(QEvent *e)▲
Reimplements: QAbstractTransition::event(QEvent *e).
[override virtual protected] bool QSignalTransition::eventTest(QEvent *event)▲
Reimplements: QAbstractTransition::eventTest(QEvent *event).
The default implementation returns true if the event is a QStateMachine::SignalEvent object and the event's sender and signal index match this transition, and returns false otherwise.
[override virtual protected] void QSignalTransition::onTransition(QEvent *event)▲
Reimplements: QAbstractTransition::onTransition(QEvent *event).
const QObject *QSignalTransition::senderObject() const▲
Returns the sender object associated with this signal transition.
Getter function for property senderObject.
See Also▲
See also setSenderObject()
[since 5.4] void QSignalTransition::senderObjectChanged()▲
This signal is emitted when the senderObject property is changed.
This is a private signal. It can be used in signal connections but cannot be emitted by the user.
Notifier signal for property senderObject.
This function was introduced in Qt 5.4.
See Also▲
See also QSignalTransition::senderObject
void QSignalTransition::setSenderObject(const QObject *sender)▲
Sets the sender object associated with this signal transition.
Setter function for property senderObject.
See Also▲
See also senderObject()
void QSignalTransition::setSignal(const QByteArray &signal)▲
Sets the signal associated with this signal transition.
Setter function for property signal.
See Also▲
See also signal()
QByteArray QSignalTransition::signal() const▲
Returns the signal associated with this signal transition.
Getter function for property signal.
See Also▲
See also setSignal()
[since 5.4] void QSignalTransition::signalChanged()▲
This signal is emitted when the signal property is changed.
This is a private signal. It can be used in signal connections but cannot be emitted by the user.
Notifier signal for property signal.
This function was introduced in Qt 5.4.
See Also▲
See also QSignalTransition::signal