Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML swipeview and State Machine

QML swipeview and State Machine

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 310 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • MontanaroM Offline
    MontanaroM Offline
    Montanaro
    wrote on last edited by Montanaro
    #1

    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;
        }*
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved