Reply to topic

An unusual effect of a component over another in a QML app

Registered Member

I don't know if here is a proper place to send a QML question or not. If there is some part of this website more proper for that, please move this question to there.

I tested the QML program below on an Android device (a tablet running Android 4.4.2). The problem is that, when rackets are not moving the ball moves smoothly (and it’s OK), but when I move either racket, it affects the speed of the ball, strangely, and reduces ball's speed! These two must be independent in terms of movement and speed, but in effect this issue takes place. I don’t know why.

Will you if possible test this code on your Android device too, to see if the problem exits there as well? If yes, what could be the source of the issue and how to remedy that, please?


Code: Select all
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.5

Window {
id: window
visible: true
width: 1000; height: 800
color: "gray"

    // The components
    // --------------

    Rectangle {
        id: table
        anchors.fill: parent
        anchors.margins: 10
        y: 10
        anchors.horizontalCenter: parent.horizontalCenter
        color: "royalblue"
    Racket {
        id: blackRacket
        anchors.left: table.left
        anchors.leftMargin: width * 2
        y: table.height / 2
        color: "black"
    Racket {
        id: redRacket
        anchors.right: table.right
        anchors.rightMargin: width * 2
        y: table.height / 2
        color: "red"
    Ball {
        id: ball
      x: 150
     y: 150


Code: Select all
import QtQuick 2.12

Rectangle {
width: 18; height: 18
color: "white"
radius: width/2

Timer {   // This timer's job is merely moving the ball
     id: timer
     interval: 22; repeat: true; running: true

 onTriggered: {
     parent.x +=  0.88
     parent.y +=  0.88


Code: Select all
import QtQuick 2.12

Rectangle {
id: root
width: 15; height: 65

MouseArea {
    anchors.fill: root root
    drag.axis: Drag.YAxis
    drag.minimumY: table.y
    drag.maximumY: table.height - root.height - 10

Reply to topic


Who is online

Registered users: aleksander, Alexa [Bot], Baidu [Spider], Bing [Bot], Google [Bot], grahm, nicoleagnew, sandro4912, Sogou [Bot], Yahoo [Bot], zeroarmor