KDStateMachineEditor API Documentation  1.2
scxmlimport/main.cpp

This examples shows how to import a KDSME::StateMachine by importing a SCXML document

/*
This file is part of the KDAB State Machine Editor Library.
SPDX-FileCopyrightText: 2015-2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Kevin Funk <kevin.funk@kdab.com>
SPDX-License-Identifier: LGPL-2.1-only OR LicenseRef-KDAB-KDStateMachineEditor
Licensees holding valid commercial KDAB State Machine Editor Library
licenses may use this file in accordance with the KDAB State Machine Editor
Library License Agreement provided with the Software.
Contact info@kdab.com if any conditions of this licensing are not clear to you.
*/
#include "config-examples.h"
#include <scxmlimporter.h>
#include <state.h>
#include <statemachinescene.h>
#include <statemachineview.h>
#include <QApplication>
#include <QDebug>
#include <QFile>
#include <QScopedPointer>
using namespace KDSME;
int main(int argc, char** argv)
{
QApplication app(argc, argv);
const QString fileName = TEST_DATA_DIR "/scxml/microwave.scxml";
QFile file(fileName);
if (!file.exists()) {
qWarning() << "File does not exist:" << file.fileName();
return 1;
}
Q_ASSERT(file.open(QIODevice::ReadOnly));
ScxmlImporter parser(file.readAll());
Q_ASSERT(machine);
view.scene()->setRootState(machine.data());
view.scene()->layout();
view.resize(800, 600);
view.show();
app.exec();
}
KDSME::ScxmlImporter
Definition: scxmlimporter.h:33
QApplication::exec
int exec()
QIODevice::ReadOnly
ReadOnly
QFile::open
virtual bool open(QIODevice::OpenMode mode) override
KDSME::StateMachineView
Widget for displaying a KDSME::StateMachine in a Qt Quick based view.
Definition: statemachineview.h:40
QFile::exists
bool exists() const const
QFile::fileName
virtual QString fileName() const const override
QScopedPointer::data
T * data() const const
QApplication
QString
QScopedPointer
QIODevice::readAll
QByteArray readAll()
KDSME::ScxmlImporter::import
StateMachine * import() override
Definition: scxmlimporter.cpp:84
QFile

Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDStateMachineEditor
Create Qt State Machine metacode using a graphical user interface
https://github.com/KDAB/KDStateMachineEditor