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. Stopping and Restarting while in the background. (Save my Batt.)
Qt 6.11 is out! See what's new in the release blog

Stopping and Restarting while in the background. (Save my Batt.)

Scheduled Pinned Locked Moved Mobile and Embedded
1 Posts 1 Posters 611 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.
  • N Offline
    N Offline
    NKinney.Econolite
    wrote on last edited by
    #1

    Qt 5.1.1 and QtQuick 2.0 on Android. I have a program that shuffles over a list of colors. While running on the device if I put the application into the background by hitting home. The Application keeps running while in the background. I would like to stop this then restart it when the application is no longer in the background. How is this accomplished in Qt?

    @import QtQuick 2.0

    Rectangle {
    width: 1280
    height: 800
    color: colorList[colorNdx]
    property variant colorList: ["red", "orange", "yellow", "green", "blue", "indigo", "violet", "white", "black"]
    property int colorNdx: 0
    property int colorCount: colorList.length

    Rectangle {
        anchors.centerIn: parent
        width: 100
        height: 100
        color: "khaki"
        border.color: "black"
        border.width: 3
        radius: 50
    
        Text {
            anchors.centerIn: parent
            text: qsTr("Quit")
        }
    
        MouseArea {
            anchors.fill: parent
            onPressed: parent.color = "pink"
            onReleased: Qt.quit()
        }
    }
    
    Timer {
         interval: 2000
         running: true
         repeat: true
         onTriggered:{
             colorNdx = colorNdx === (colorCount - 1) ? 0 : (colorNdx + 1)
             console.log("color =>", colorList[colorNdx])
         }
    }
    

    }
    @

    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