QML swipeview and State Machine
-
I' m very very beginner about QML.
I'm some experience about C for micrcontroller. When I wrote code for microcontroller, i usually used State Machine.
The method for QT Quick and Ui is very similar and i can write the code.
But i dont undestand how to convert my State Machine into QML
For example this is my State Machine for Ui, how i can convert to QML ? (QML is better for my graphic, i have to use draw and not text in my next code)*MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);ui->label->setStyleSheet("QLabel { background-color : black; color : white; }"); ui->label->setText("Welcome"); QTimer *timer = new QTimer(this); connect (timer, SIGNAL(timeout()), this, SLOT(StateMachine())); // timer->start(FREQUENCY); //}
void MainWindow::StateMachine() { QFile k1_file("/sys/class/GIROLO/input_key1"); // k1_file.open(QIODevice::ReadOnly | QIODevice::Text); QFile k2_file("/sys/class/GIROLO/input_key2"); // k2_file.open(QIODevice::ReadOnly | QIODevice::Text); QFile k3_file("/sys/class/GIROLO/input_key3"); // k3_file.open(QIODevice::ReadOnly | QIODevice::Text); QFile k4_file("/sys/class/GIROLO/input_key4"); // k4_file.open(QIODevice::ReadOnly | QIODevice::Text); QTextStream stream1(&k1_file); // QString numberS1 = stream1.readAll(); number1=numberS1.toInt(); QTextStream stream2(&k2_file); QString numberS2 = stream2.readAll(); number2=numberS2.toInt(); QTextStream stream3(&k3_file); QString numberS3 = stream3.readAll(); number3=numberS3.toInt(); QTextStream stream4(&k4_file); QString numberS4 = stream4.readAll(); number4=numberS4.toInt(); switch(step) { // start: in this case, we show a slide with welcome // case WELCOME : ui->label->setText("Welcome"); qDebug() << "case 1 : WELCOME "; flagBad1=0; flagGood1=0; // mainCount=0; flagBad2=0; flagGood2=0; qDebug() << number3; if (number3==1) { step=LIST1; } break; // in this case, we show a list of instruction // the case has a list of instruction in several slides. // before changing slide, we have to choose BAD or GOOD flag case LIST1: qDebug() << "case 1 : LIST1 "; ui->label->setText("INSTRUCTION1"); if(number2==1) { qDebug() << "flag good"; ui->label->setText("ISTRUCTION1 \n"); ui->label->setText("flag good"); flagGood1=1; flagBad1=0; } else if (number4==1) { qDebug() << "flag bad "; ui->label->setText("INSTRUCTION1 "); ui->label->setText("flag bad"); flagBad1=1; flagGood1=0; } if (( number3==1) && ((flagGood1==1)||(flagBad1==1))) { qDebug() << "GO TO NEXT INST"; ui->label->setText("NEXT INSTRUCTION"); step= LIST2; }*