Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML MouseEvent
Forum Updated to NodeBB v4.3 + New Features

QML MouseEvent

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 1.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    narayanan.krish
    wrote on last edited by
    #1

    Hello all !!
    I am having two qml files, main.qml & task.qml. I am launching task.qml on a mouse click from main.qml using Qt.createComponent.

    The mouseEvent from task.qml passes to main.qml.
    My understanding is when I create the dynamic component the mouse events from task.qml will not pass to main.qml.
    Kindly clear me If I am wrong.
    kindly help me to fix it.

    Thanks & Regards,
    Narayanan K

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      AFAIK, QML engine makes no distinction between statically and dynamically generated components.

      If you want to stop a mouseEvent being passed around, you need to accept it at some level with:
      @
      // for example:
      onClicked: {
      mouse.accepted = true;
      }
      @

      (Z(:^

      1 Reply Last reply
      0
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #3

        AFAIK, QML engine makes no distinction between statically and dynamically generated components.

        If you want to stop a mouseEvent being passed around, you need to accept it at some level with something like this:
        @
        onClicked: {
        mouse.accepted = true;
        }
        @

        (Z(:^

        1 Reply Last reply
        0
        • N Offline
          N Offline
          narayanan.krish
          wrote on last edited by
          #4

          Hi,

          The following are my qml codes. I am creating the task component on a mouse click on main.qml.

          Can you please specify where I have to accept/reject the mouse events.

          main.qml
          @

          import QtQuick 2.0
          import "Test.js" as Test
          import "Global.js" as GlobalJS

          Rectangle {
          id: root
          width:800
          height:480

          Image {
              id: bg
              source: "../../resources/images/Home_Screen/bg.png"
              x: 0
              y: 0
              opacity: 1
          }
          
          
          Image 
          {
              id: task_manager
              source: "../../resources/images/Home_Screen/task_manager.png"
              x: 219
              y: 342
              opacity: 1
          

          MouseArea
          {
          anchors.fill: parent
          onClicked:
          { GlobalJS.dynamic_component_task=Qt.createComponent("TaskManager.qml").createObject(root, {});
          }
          }
          }

          Image 
          {
              id: about
              source: "../../resources/images/Home_Screen/about.png"
              x: 544
              y: 297
              opacity: 1
          

          MouseArea
          {
          anchors.fill: parent
          onClicked:
          {
          Qt.createComponent("About_Screen.qml").createObject(root, {});
          }
          }
          }
          }
          @

          Task.qml

          @
          import QtQuick 2.0

          Rectangle
          {
          id: rect
          x:0
          y:0
          width:800
          height:480

          Image {
          id: bg1
          source: "../../resources/images/Home_Screen/Task_Manager/bg.png"
          x: 0
          y: 0
          opacity: 1
          }

          Text {
              id: task_manager
              text: "Task Manager"
              font.pixelSize: 20
              font.family: "Arial-BoldMT"
              font.bold: true
              color: "#8bfcfd"
              smooth: true
              x: 400
              y: 10
              opacity: 1
          }
          

          Text {
          id: processText
          x:150
          y:120
          text: "RUNNING"
          font.pixelSize: 18
          font.family: "SegoeUI"
          color: "#8bfcfd"
          smooth: true
          opacity: 1

          }

          Text {
          x:400
          y:120
          text: "CPU"
          font.pixelSize: 18
          font.family: "SegoeUI"
          color: "#8bfcfd"
          smooth: true
          opacity: 1

          }

          Text {
          id: memText
          x:620
          y:120
          text: "MEMORY"
          font.pixelSize: 18
          font.family: "SegoeUI"
          color: "#8bfcfd"
          smooth: true
          opacity: 1

          }

          Image {
          id: refresh
          source: "../../resources/images/Home_Screen/Task_Manager/refresh.png"
          x: 274
          y: 414
          opacity: 1
          MouseArea
          {
          anchors.fill: parent
          onClicked:
          {
          console.log("refresh ... ");

          }
          }
          }

          Image {
              id: end
              source: "../../resources/images/Home_Screen/Task_Manager/end.png"
              x: 452
              y: 414
              opacity: 1
          

          MouseArea
          {
          anchors.fill: parent
          onClicked:
          {
          console.log("end the process ");

          }
          }
          }
          }
          @

          Kindly help me to fix this.

          Thanks & Regards,
          Narayanan K

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved