Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
QML Pase los eventos del mouse al elemento creado presionando presione

Tengo un elemento que crea un nuevo elemento por el evento onPressed, el elemento creado tiene su propio MouseArea con las funciones onPressed y onPositionChanged. Ahora tengo que volver a pulsar sobre el nuevo elemento para interactuar con él. ¿Cómo puedo hacer que el nuevo elemento reaccione inmediatamente a los eventos del mouse (cuando se presiona el botón del mouse)?

 import QtQuick 2.11 import QtQuick.Window 2.11 Window { visible: true width: 640 height: 480 title: qsTr("Hello World") Rectangle { id: start width: 100 height: 100 anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter color: "red" Component { id: comp Rectangle { x: start.x y: start.y width: start.width height: start.height color: "blue" MouseArea { anchors.fill: parent onPositionChanged: { console.log(mouse.x, mouse.y) if (mouse.x < 0) { parent.x += mouse.x } if (mouse.y < 0) { parent.y += mouse.y } if (mouse.x > parent.width) { parent.x += mouse.x - parent.width } if (mouse.y > parent.height) { parent.y += mouse.y - parent.height } } } } } MouseArea { anchors.fill: parent property Item obj onPressed: { obj = comp.createObject(start.parent); if (obj === null) { console.log("Error creating object"); } } } } }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!