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. [solved] Collision detect of items doesn't work or suported in Quick 2.0!
Qt 6.11 is out! See what's new in the release blog

[solved] Collision detect of items doesn't work or suported in Quick 2.0!

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 1.8k 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.
  • J Offline
    J Offline
    jackmack
    wrote on last edited by
    #1

    Hi all!

    First, I know there are a lot of threads posted about that topic. I have read all, also googled and spent a lot of time - without any success :-(

    I use Qt 5.2 with Quick 2.0 to implement a very simple game. There are some items placed in the main view (collectables). Then there is a dragable item (catcher) which you can dragging around the main view. Always when the catcher collids with a collectable I want to recognize that. THAT'S ALL what I want!

    *Please guys: *
    Don't tell me yet there are a lot of 3rd party libs available like Box2D or you can do that all with JS! No comments, only facts/examples please! I have read too much threads without any results - only trash talk, no solutions.

    Earlier in an older application I used the Graphics Framework which is behind the Quick 1. There is a QGraphicsItem class with collidingItems() method. Great! But since Quick 2 the complete render system changed to OpenGL and what ever. The new corresponding class QQuickItem doesn't have any such colliding methods.

    I think it's very poor if such a greatful, complex framework like Quick 2 doesn't support that elementary functions like collison detects. That throws Quick back to the dark age.

    Ok, I can change back to Quick 1 but the docs says: Newer applications should use Quick 2.
    Or is going back to Quick 1 actually the best way? How is the port of Quick 1 to Android?

    Have anybody a simple, clear suggestion how I can implement a collision detect in Quick 2?

    I tried something like that in JS where x, y comes from the dragable item (iterating about all childs):

    @function collisionDetect(x, y) {

    for (var i; i < mainView.children.length; i++) {
    var item = mainView.children[i]
    if (item.contains(x, y) && item.objectName == "collectable")
    console.log("yeahh!")
    }
    @

    But the contains() returns always true! What a f...!
    I have tested it with a global MouseArea, catched in onClicked the position and passed it also to contains(). The same: Always true! But the point is definitly outside the item!

    Thanks for any answers.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jackmack
      wrote on last edited by
      #2

      See https://bugreports.qt-project.org/browse/QTBUG-34712

      It a bug in Item.contains() :-(

      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