PySide6.QtStateMachine.QSignalTransition

class QSignalTransition

The QSignalTransition class provides a transition based on a Qt signal. More

Inheritance diagram of PySide6.QtStateMachine.QSignalTransition

Synopsis

Properties

  • senderObjectᅟ - The sender object that this signal transition is associated with

  • signalᅟ - The signal that this signal transition is associated with

Methods

Signals

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description

Typically you would use the overload of 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 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<QStateMachine::SignalEvent*>(e);
        return (se->arguments().at(0).toInt() == Qt::Checked);
    }
};

...

QCheckBox *check = new QCheckBox();
check->setTristate(true);

QState *s1 = new QState();
QState *s2 = new QState();
CheckedTransition *t1 = new CheckedTransition(check);
t1->setTargetState(s2);
s1->addTransition(t1);

Note

Properties can be used directly when from __feature__ import true_property is used or via accessor functions otherwise.

property senderObjectᅟ: QObject

This property holds the sender object that this signal transition is associated with.

Access functions:
property signalᅟ: QByteArray

This property holds the signal that this signal transition is associated with.

Access functions:
__init__([sourceState=None])
Parameters:

sourceStateQState

Constructs a new signal transition with the given sourceState.

__init__(signal[, state=None])
Parameters:
  • signal – object

  • stateQState

__init__(sender, signal[, sourceState=None])
Parameters:

Constructs a new signal transition associated with the given signal of the given sender, and with the given sourceState.

senderObject()
Return type:

QObject

Returns the sender object associated with this signal transition.

Getter of property senderObjectᅟ .

senderObjectChanged()

This signal is emitted when the senderObject property is changed.

Notification signal of property senderObjectᅟ .

setSenderObject(sender)
Parameters:

senderQObject

Sets the sender object associated with this signal transition.

See also

senderObject()

Setter of property senderObjectᅟ .

setSignal(signal)
Parameters:

signalQByteArray

Sets the signal associated with this signal transition.

See also

signal()

Setter of property signalᅟ .

signal()
Return type:

QByteArray

Returns the signal associated with this signal transition.

See also

setSignal()

Getter of property signalᅟ .

signalChanged()

This signal is emitted when the signal property is changed.

Notification signal of property signalᅟ .