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. Display various size of ListElements with GridView

Display various size of ListElements with GridView

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 1.1k 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.
  • X Offline
    X Offline
    xela
    wrote on last edited by
    #1

    Hello Experts,

    my goal is to design a UI like the windows phone (example), with rezieable tiles and automatic reassabling of the items and various items height and width. I posted already a question at StackOverflow with more information.

    Display variuos size of ListElements with GridView

    After trying and failing for long time, I'am almost sure I use the wrong approach.
    I used the GridView Demo from QT and tried to modify it, but I failed.
    Maybe on of you experts can give me a hint for solving this. I'm relatively new at QML but willing to learn and motivated. Hope you can help. Thanks in advance!

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Ray Gray
      wrote on last edited by
      #2

      I don't believe that GridView can be tricked to handle elements of different sizes (at least not without a lot of hacky code). I would go with custom solution here.

      1 Reply Last reply
      0
      • X Offline
        X Offline
        xela
        wrote on last edited by
        #3

        Hello Qt-Experts,

        following up on my "old" request, I ended up accepting that I have to solve my problem on the hard way. Now, playing around with DropArea, I found out some issues, I cannot bring in consens with the Qt manpage.

        This is the expamle-code:

            Rectangle {
                id:dropRect
                property var droppedObject
                anchors {
                    top: parent.top
                    right:  parent.right
                    bottom:  parent.bottom
                }
                width: parent.width / 2
                color: "gold"
                DropArea {
                    id: dropZone
                    anchors.fill: parent
        
                    onContainsDragChanged: {
                        var i = 1
                    }
        
                    onEntered:{
                           if (dropRect.droppedObject === undefined) {
                           dropRect.droppedObject = drag.source
                           drag.source.caught = true;
                           }
                    }
                    onExited: {
                            dropRect.droppedObject = undefined
                            drag.source.caught = false;
                    }
                    onDropped: {
                        dropRect.droppedObject = drag.source
                    }
                }
            }
        

        Ok, lets start with first issue: I can only use QtQuick 2.5 in this project. Need to know, because the documentation states 2.7.

        For code explanation:
        dopZone.containsDrag is only true, if the drag is moved. stopping the movement will set "containsDrag" to false immediately. Also dropZone.drag.source is null when the drag is not moving. I proved this by using a timer which prints out both in 10ms interval.
        So for my project, I have to check if the dropZone already contains an object. This is why I did:

                    onEntered:{
                           if (dropRect.droppedObject === undefined) {
                           dropRect.droppedObject = drag.source
                           drag.source.caught = true;
                           }
                    }
        

        This piece is working at the first glance, but then I faced an issue. If the object leaves the area, I have to set

        onExited: {
                            dropRect.droppedObject = undefined
                            drag.source.caught = false;
                    }
        

        So far so good. The problem is, that onExited is also emitted, when I only drop the Drag. The manual states:

        exited()
        
        This signal is emitted when a drag exits the bounds of a DropArea.
        
        The corresponding handler is onExited.
        

        Source
        So my understanding is, that my drag did not leave the bounds of the DropArea, but onExited is emitted anyway.

        Next issue:

        onDropped: {
                        dropRect.droppedObject = drag.source
                    }
        

        onDropped is never emitted. Manual states:

        dropped(DragEvent drop)
        
        This signal is emitted when a drop event occurs within the bounds of a DropArea.
        
        The corresponding handler is onDropped.
        

        Source

        Can anyone give me a hint why this signal is not emitted? Is there another way to find out when a drag is dropped?

        MAybe all this issues are caused because I use 2.5 instead of 2.7, maybe they are caused because I have a misunderstanding of the manual. Anyway, to proceed, it would be great if someone can give me some hints or workarounds.

        Thank you all guys in advance.

        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