Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

151
Visualizações
QML Checking for the cross of elements with different parents

I have many elements of the same type (Point.qml) at different nesting levels. How can I check that some element (id: checker) cross one of these elements (Point)?

For Example:

// Point.qml
import QtQuick 2.0

Rectangle {

   width: 10
   height: 10

   color: "black"

}
// main.qml
import QtQuick 2.11
import QtQuick.Window 2.11
import QtQuick.Layouts 1.3

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")


    Rectangle {
        id: area;
        anchors.fill:  parent


        RowLayout
        {
            anchors.fill:  parent

            Repeater
            {
                model: 5
                Rectangle
                {
                    width: Math.random()*150+50
                    height: Math.random()*150+50
                    color: "blue"

                    Point {
                        x : Math.random()*parent.width
                        y : Math.random()*parent.height
                    }

                }
            }
            Point {
                x : Math.random()*parent.width
                y : Math.random()*parent.height
            }

        }
        Point {
            x : Math.random()*parent.width
            y : Math.random()*parent.height
        }



        Rectangle
        {
            id: checker

            width: 60
            height: 60
            color: "red"
            opacity: 0.5

            MouseArea
            {
                anchors.fill: parent
                drag.target: parent

                onReleased:
                {
                    var point = getCoveredPoint()
                    if (point)
                    {
                        console.log("Point ", point, " is covered")
                    }
                }

                function getCoveredPoint()
                {
                    var point
                    // do something
                    return point
                }
            }
        }
    }

}

In this example, when the red Rectangle (id: checker) stops at the black Point, a message should be output to the console. Points and "checker" are in the same parent element (id: area)

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda