[bug] MouseEvent x and y properties are floats

asked 2015-04-03 00:25:03 +0300

MartinK gravatar image

updated 2015-04-12 22:32:35 +0300

Description of problem:

The MouseEvent QML type properties x and y are floating point numbers with arbitrary precision even though they should be integers as specified by the Qt documentation and confirmed on desktop Qt.

Version-Release number of selected component (if applicable):

Name: qt5-qtdeclarative-qtquick Version: 5.2.1+git19-1.23.3

How reproducible:

always

Steps to Reproduce:

  1. save the following to file and run it with qmlscene:

    import QtQuick 2.0

    MouseArea { width : 800 height : 600 onPositionChanged : { console.log("mouse pointer x,y:") console.log(mouse.x + "," + mouse.y) } }

  2. tap the screen and move your finger

Actual results:

The MouseEvent x and y properties are floating point numbers with arbitrary precission.

Example output:

[D] onPositionChanged:7 - mouse pointer x,y:
[D] onPositionChanged:8 - 410.1300048828125,430.5404968261719
[D] onPositionChanged:7 - mouse pointer x,y:
[D] onPositionChanged:8 - 411.1098937988281,432.55950927734375
[D] onPositionChanged:7 - mouse pointer x,y:
[D] onPositionChanged:8 - 412.0899963378906,433.56890869140625
[D] onPositionChanged:7 - mouse pointer x,y:
[D] onPositionChanged:8 - 408.1698913574219,433.56890869140625
[D] onPositionChanged:7 - mouse pointer x,y:
[D] onPositionChanged:8 - 403.2699890136719,432.55950927734375
[D] onPositionChanged:7 - mouse pointer x,y:
[D] onPositionChanged:8 - 390.0400085449219,427.5120849609375
[D] onPositionChanged:7 - mouse pointer x,y:
[D] onPositionChanged:8 - 377.7898864746094,421.4552001953125
[D] onPositionChanged:7 - mouse pointer x,y:
[D] onPositionChanged:8 - 363.5799865722656,415.9031066894531
[D] onPositionChanged:7 - mouse pointer x,y:
[D] onPositionChanged:8 - 345.94000244140625,406.8179016113281
[D] onPositionChanged:7 - mouse pointer x,y:
[D] onPositionChanged:8 - 341.5299987792969,403.78948974609375

Expected results:

The MouseEvent x and y properties are integers.

Example output with desktop Qt (Qt 5.4 on Fedora 21):

qml: mouse pointer x,y:
qml: 513,316
qml: mouse pointer x,y:
qml: 499,332
qml: mouse pointer x,y:
qml: 461,360
qml: mouse pointer x,y:
qml: 438,375
qml: mouse pointer x,y:
qml: 387,402
qml: mouse pointer x,y:
qml: 356,411
qml: mouse pointer x,y:
qml: 325,420
qml: mouse pointer x,y:
qml: 270,429
qml: mouse pointer x,y:
qml: 241,431
qml: mouse pointer x,y:
qml: 194,433
qml: mouse pointer x,y:
qml: 173,433
qml: mouse pointer x,y:
qml: 146,433
qml: mouse pointer x,y:
qml: 135,433

Additional info:

Unlike integers, floating point numbers often loose precision during mathematical operations and this could cause serious issues for application that expect the pointer coordinates to be integers and don't expect the precision loss. Also other issues caused by a float showing up somewhere integer is supposed to be can be expected.

Update

Filled on the Mer Bugzilla as 880.

edit retag flag offensive close delete