QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCState Class Reference

#include <QGCState.h>

+ Inheritance diagram for QGCState:
+ Collaboration diagram for QGCState:

Public Member Functions

 QGCState (const QString &stateName, QState *parentState)
 
template<typename PointerToMemberFunction >
QSignalTransition * addThisTransition (PointerToMemberFunction signal, QAbstractState *target)
 Simpler version of QState::addTransition which assumes the sender is this.
 
void setLocalErrorState (QAbstractState *errorState)
 
QAbstractState * localErrorState () const
 Get the per-state error state (nullptr if using global)
 
void setProperty (QObject *object, const char *name, const QVariant &value)
 
void setEnabled (QObject *object, bool enabled)
 Convenience overload for setting enabled state on widgets/controls.
 
void setVisible (QObject *object, bool visible)
 Convenience overload for setting visible state on widgets/controls.
 
- Public Member Functions inherited from QGCAbstractState
 QGCAbstractState (const QString &stateName, QState *parent)
 
QGCStateMachinemachine () const
 
Vehiclevehicle () const
 
QString stateName () const
 
class StateContextcontext () const
 
void setOnEntry (EntryCallback callback)
 Set a callback to be invoked when the state is entered.
 
void setOnExit (ExitCallback callback)
 Set a callback to be invoked when the state is exited.
 
void setCallbacks (EntryCallback onEntry, ExitCallback onExit=nullptr)
 Set both entry and exit callbacks.
 
void setEventHandler (EventHandler handler)
 Set a custom event handler for this state.
 

Additional Inherited Members

- Public Types inherited from QGCAbstractState
using EntryCallback = std::function< void()>
 
using ExitCallback = std::function< void()>
 
using EventHandler = std::function< bool(QEvent *)>
 
- Signals inherited from QGCAbstractState
void advance ()
 
void error ()
 
- Protected Member Functions inherited from QGCAbstractState
virtual void onEnter ()
 Override to perform actions on state entry.
 
virtual void onLeave ()
 Override to perform actions on state exit.
 
void onEntry (QEvent *event) override
 
void onExit (QEvent *event) override
 
bool event (QEvent *event) override
 

Detailed Description

Full-featured base class for QGroundControl state machine states.

Extends QGCAbstractState with:

  • Local per-state error handling (setLocalErrorState)
  • Property assignment support (setProperty, setEnabled, setVisible)
  • Convenience transition helper (addThisTransition)

Use QGCAbstractState when you only need callback-driven entry/exit. Use QGCState when you need the extra features listed above.

Definition at line 21 of file QGCState.h.

Constructor & Destructor Documentation

◆ QGCState()

QGCState::QGCState ( const QString &  stateName,
QState *  parentState 
)

Definition at line 6 of file QGCState.cc.

Member Function Documentation

◆ addThisTransition()

template<typename PointerToMemberFunction >
QSignalTransition * QGCState::addThisTransition ( PointerToMemberFunction  signal,
QAbstractState *  target 
)
inline

Simpler version of QState::addTransition which assumes the sender is this.

Definition at line 30 of file QGCState.h.

◆ localErrorState()

QAbstractState * QGCState::localErrorState ( ) const
inline

Get the per-state error state (nullptr if using global)

Definition at line 42 of file QGCState.h.

◆ setEnabled()

void QGCState::setEnabled ( QObject *  object,
bool  enabled 
)

Convenience overload for setting enabled state on widgets/controls.

Definition at line 25 of file QGCState.cc.

◆ setLocalErrorState()

void QGCState::setLocalErrorState ( QAbstractState *  errorState)

Set a per-state error handler that overrides the global error state

Parameters
errorStateThe state to transition to on error for this state only

Definition at line 11 of file QGCState.cc.

References QGCAbstractState::error(), and QGCAbstractState::stateName().

◆ setProperty()

void QGCState::setProperty ( QObject *  object,
const char *  name,
const QVariant &  value 
)

Assign a property value when this state is entered If RestoreProperties policy is set on the machine, the value is restored on exit

Parameters
objectThe QObject to modify
nameThe property name
valueThe value to assign

Definition at line 20 of file QGCState.cc.

◆ setVisible()

void QGCState::setVisible ( QObject *  object,
bool  visible 
)

Convenience overload for setting visible state on widgets/controls.

Definition at line 30 of file QGCState.cc.


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