Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QML refresh
Forum Updated to NodeBB v4.3 + New Features

QML refresh

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 2 Posters 2.5k 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.
  • L Offline
    L Offline
    leemic
    wrote on last edited by
    #1
    • I wanna do something like this

    if start clicked
    start timer trigger {
    can_Start(); //This should refresh every second
    }

    if stop clicked
    stop timer trigger {
    can_Start(); //Disable from refreshing
    can_Stop(); //This should refresh every second
    }

    if setup clicked
    can_Setup(); //Run only once from start to end of program

    ** in the following code
    @
    import QtQuick 1.1

    Rectangle {
    id: mainWindow
    width: 800
    height: 480
    color: "#00000000"

    signal signalReceived1;
    function updateReceived1(text) {
        c410_out_text1.text = text+" %"
    }
    signal signalReceived2;
    function updateReceived2(text) {
        c410_out_text2.text = text+" DegC"
    }
    signal signalReceived3;
    function updateReceived3(text) {
        c410_out_text3.text = text
    }
    signal signalReceived4;
    function updateReceived4(text) {
        c410_out_text4.text = text+" amps"
    }
    
    function currentDateTime() {
        var today = new Date();
        today.setDate(today.getDate())
        dateTime_text.text = Qt.formatDateTime(today, "MM/dd/yyyy");
    }
    
    function onStartSetText(){
        if (stop_text.focus == true) {
            c410_out_text1 = ""         //clear text
            c410_out_text2 = ""         //clear text
            c410_out_text3 = ""         //clear text
            c410_out_text4 = ""         //clear text
        }
    }
    
    property bool ok: false
    property int num: 0
    
    property string setup       //Pass setup button value
    function can_Setup(){
        setup = setup_text.text;
        start = "";
        stop = "";
        CANReceiver.canConfig(setup, start, stop);
        console.log("Setup Clicked");
    
    }
    
    property string start       //Pass start button value
    function can_Start(){
        setup = "";
        start = start_text.text;
        stop = "";
        CANReceiver.canConfig(setup, start, stop);
        signalReceived1();
        signalReceived2();
        signalReceived3();
        signalReceived4();
        console.log("Start Clicked");
    }
    
    property string stop        //Pass stop button value
    function can_Stop(){
        setup = "";
        start = "";
        stop = stop_text.text;
        CANReceiver.canConfig(setup, start, stop);
        onStartSetText();
        console.log("Stop Clicked");
    }
    
    function allCan(){
        if (stop_text.text == "Stop"){
            can_Stop();
        }else if (start_text.text == "Start"){
            can_Start()
        }
    }
    
        Text {
            id: c410_out_text1
            x: 187
            y: 1
            width: 490
            height: 50
            font.pixelSize: 12
            Timer {
                repeat: true
                running: true
                triggeredOnStart: true
                interval: 1000
                onTriggered: {
                    allCan();
                }
            }
            font.bold: true
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
        }
    
    Rectangle {
        id: start_rec
        x: 60
        y: 110
        width: 150
        height: 50
        color: "#000000"
    
    
        MouseArea {
            id: start_mousearea
            x: 0
            y: 0
            width: 150
            height: 50
            onPressed: { start_rec.opacity = .8 }
            onReleased: { start_rec.opacity = 1 }
            onClicked: {
    
            }
        }
    
        Text {
            id: start_text
            x: 0
            y: 0
            width: 150
            height: 50
            color: "#ffffff"
            text: qsTr("Start")
            font.pointSize: 13
            font.bold: true
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            font.pixelSize: 12
        }
    
        Item {
            id: start_item
            x: 0
            y: 0
            width: 150
            height: 50
        }
    
    
    }
    
    Rectangle {
        id: stop_rec
        x: 590
        y: 110
        width: 150
        height: 50
        color: "#000000"
        MouseArea {
            id: stop_mousearea
            x: 0
            y: 0
            width: 150
            height: 50
            onPressed: { stop_rec.opacity = .8 }
            onReleased: { stop_rec.opacity = 1 }
            onClicked: {
            }
        }
    
        Text {
            id: stop_text
            x: 0
            y: 0
            width: 150
            height: 50
            color: "#ffffff"
            text: qsTr("Stop")
            font.pixelSize: 12
            font.bold: true
            font.pointSize: 13
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
        }
    
        Item {
            id: stop_item
            x: 0
            y: 0
            width: 150
            height: 50
        }
    
    
    }
    
    Rectangle {
        id: setup_rec
        x: 319
        y: 110
        width: 150
        height: 50
        color: "#000000"
        MouseArea {
            id: setup_mousearea
            x: 0
            y: 0
            width: 150
            height: 50
            onPressed: { setup_rec.opacity = .8 }
            onReleased: { setup_rec.opacity = 1 }
            onClicked: {
            }
        }
    
        Text {
            id: setup_text
            x: 0
            y: 0
            width: 150
            height: 50
            color: "#ffffff"
            text: qsTr("Setup")
            font.pixelSize: 12
            font.bold: true
            font.pointSize: 13
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
        }
    
        Item {
            id: setup_item
            x: 0
            y: 0
            width: 150
            height: 50
        }
    }
    

    }@

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kolegs
      wrote on last edited by
      #2

      I think you can easily implement it using "Timer":http://qt-project.org/doc/qt-5.0/qtqml/qml-qtquick2-timer.html in QML

      1 Reply Last reply
      0
      • L Offline
        L Offline
        leemic
        wrote on last edited by
        #3

        I am a beginner so not yet familiar with all of it can u show me in the up example how

        1 Reply Last reply
        0
        • L Offline
          L Offline
          leemic
          wrote on last edited by
          #4

          Thanks got it fixed, i gave an id for the timer and called it with id.start();

          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