QML Screen Coordinates of Component

Paul Carlisle

If I have a simple, self-contained QML application, I can get the absolute screen coordinates of a component by saying

Component.onCompeted: {    
    var l = myThing.mapToItem(null, 0, 0)
    console.log("X: " + l.x + " y: " + l.y)
}

where myThing is the id of any other component in the file. However, if this file gets incorporated into another QML file and the component it defines is reused, I don't get the screen coordinates anymore; I get the local coordinates relative to the component where the statements above are executed.

How can I get the absolute screen coordinates of items?

Simon Warta
Component.onCompleted: {
    var globalCoordinares = myThing.mapToItem(myThing.parent, 0, 0)
    console.log("X: " + globalCoordinares.x + " y: " + globalCoordinares.y)
}

where myThing.parent is your main compontent.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

QML Component Screen Rendering

From Dev

QML-maps: get coordinates when tap the screen

From Dev

How can I get a component's position on screen (screen coordinates)

From Dev

Drag coordinates of a QML shape

From Dev

Transformation the screen coordinates to stage coordinates

From Dev

QML accessing your qml component

From Dev

Screen coordinates in R

From Dev

Display touch coordinates on screen

From Dev

Mapping coordinates to screen in PyGame

From Dev

QML screen orientation lock

From Dev

Qml - ReferenceError: Screen is not defined

From Dev

QML screen orientation lock

From Dev

How to convert workspace coordinates to screen coordinates?

From Dev

How to convert screen coordinates to control coordinates

From Dev

screen coordinates to sharpdx device context coordinates

From Dev

How to convert workspace coordinates to screen coordinates?

From Dev

How to get object coordinates from screen coordinates?

From Dev

Reusing a delegate component in QML

From Dev

Alias method in QML component

From Dev

Reusing a delegate component in QML

From Dev

Are the coordinates in WINDOWPOS on WM_WINDOWPOSCHANGED in parent coordinates or screen coordinates?

From Dev

How to calculate transformation from screen coordinates to isometric screen coordinates?

From Dev

Points coordinates in multiple screen CoronaSDK

From Dev

gl_PointSize to screen coordinates

From Dev

GetWindowRect coordinates not screen-relative

From Dev

Get the center coordinates of phone screen

From Dev

Get Screen-Coordinates of a QuickControl

From Dev

Get the center coordinates of phone screen

From Dev

Get coordinates (screen) of GridLayout items

Related Related

HotTag

Archive