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. Retrieving a large list of objects from C++ for Qt3D Quick display
Forum Updated to NodeBB v4.3 + New Features

Retrieving a large list of objects from C++ for Qt3D Quick display

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

    I am writing an application that will let users pick stuff from a scrollable list of objects(represented as icons in the list). Then drop them to a 3D Viewer. Then the user clicks 'Play' and these objects move.

    Its for a physics simulation where the objects to be added are in the list. So the interface is quite simple and I wanted to create it in QML. The simulation classes are in C++ (Bullet Physics). I am planning to make the 3D Viewer where the objects can be seen moving(following the laws of physics), in Qt3D Quick.

    The way I am hoping to make this work is, the 3D Viewer calls 2 C++ functions in each frame :

    1. stepSimulation() - does the simulation for the time elapsed since the last call, very small intervals are buffered
    2. retrieveObjects - this gets the list of objects from the C++ code.

    My concern is how to achieve (2). Is it possible to retrieve a std::vector<MyObjectCLass> from C++ into QML ?

    Also does Qt3D Quick support moderately complex 3D scenes and camera movements. How about GLSL shaders ?

    How would one go about achieving drag and drop functionality in this application. Here users would pick from the scrollable list and drag to the 3D Viewer - just like in Maya or 3DS Max. So the Qt3D Quick view should be able to accept the drag and drop event.

    1 Reply Last reply
    0
    • O Offline
      O Offline
      onek24
      wrote on last edited by
      #2

      Hello and welcome to qt-project.org,

      i may not help you about the Qt3D part, but maybe the drag and drop part. Are these objects which you want to drag and drop size-fixed? If so, then you can use a ListView or GridView.

      For further information and examples please read: "Drag and Drop":http://qt-project.org/doc/qt-5.0/qtquick/draganddrop.html

      If you want to have custom cells, then you have to create your own handler for this. Currently i am working on a handler which has got custom dragable components as childs and a mesh where he looks the grids up. The childs trigger a function in the Handler passing their new coordinates, the handler looks up in the table and updates all components based on the new position of the component.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        modeldancecontroller
        wrote on last edited by
        #3

        Thanks for the reply. Here is what I have in mind :

        @ _______________________________________________
        |O1|O2|||||____| <----- List of icons
        | |
        | | |
        | | _____ <-------3D Viewer
        | / |
        |_____________ ________________________|
        |Simulate!Stop
        |<---------controls @

        1 Reply Last reply
        0
        • O Offline
          O Offline
          onek24
          wrote on last edited by
          #4

          What do you want to have drag and dropable? Only the list of icons or everything including your controls and the viewer so you can reposition as needet?

          1 Reply Last reply
          0
          • M Offline
            M Offline
            modeldancecontroller
            wrote on last edited by
            #5

            Only the list of icons. So the user clicks something in the list and then drags it to the 3D Viewer. Then this sphere or cube appears in the 3D Viewer when the drag is complete.

            I do not need drag and drop necessarily of course as the user can simply click on the icon in the list of objects then click again in the 3D Viewer viewport, and then the object appears there - in that case we do not need the drag and drop of course, but it would be good to have :)

            The position of the controls are fixed as they are for controlling the simulation so the user should not mess with them.

            1 Reply Last reply
            0
            • O Offline
              O Offline
              onek24
              wrote on last edited by
              #6

              Alright so it is basically just a drag. For that you can use a MouseArea as a child of each Icon:
              @MouseArea {
              drag.target: parent
              drag.axis: Drag.XAndYAxis
              onReleased {
              if(MouseX >= 3dviewer.x && MouseX <= 3dviewer.x+3dviewer.width){
              if(MouseX >= 3dviewer.y && MouseY <= 3dviewer.y+3dviewer.height){
              // Inside the 3d viewer, display it in 3d
              //dont let it drop here just let it move back to it's position
              }
              }
              }@

              It may be not 100% correct because i have typed it in the reply-box and not in Qt. But it should look somehow like that. Also don't forget to set drag.MinimumX / drag.MinimumY and drag.MaximumX / drag.MaximumY.

              For further information please read: "MouseArea":http://qt-project.org/doc/qt-5.0/qtquick/qml-qtquick2-mousearea.html

              1 Reply Last reply
              0
              • M Offline
                M Offline
                modeldancecontroller
                wrote on last edited by
                #7

                Thanks. I will try it out. What do you mean by

                bq. let it move back to it's position.

                Also I need to have a MouseArea for every icon ? So if there are 100 icons, then each need one ? Or can I just have MouseAreas for the ones currently visible in the list.

                The list of icons is just like a sideways scrolling roll of photos as can be seen in the Flickr photo viewing app for example. There will be an arrow at the right side to allow scrolling further right to see more object icons. The icons which are no longer visible do not need MouseAreas I guess. Maybe I can put in some logic to implement that.

                1 Reply Last reply
                0
                • O Offline
                  O Offline
                  onek24
                  wrote on last edited by
                  #8

                  By "let it move back to it's position." i mean that your icon should move back to it's position in the list of icons and not disappear.

                  Well you probably will need a MouseArea for each Icon, but you could also assign them dynamically like you probably will do with your icons, so each icon will have a child mousearea which behavors like it is the child of a icon.

                  You are probably using a ListView for your Iconlist so a icon would be a delegate of it, and so would be the MouseArea so only visible MouseAreas are dragable and "available".
                  Otherwise you could check in onXChanged or onYChanged if your MouseArea is in the visible Area or not and handle that somehow.

                  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