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. Animated Items in Gridview hides behind following items

Animated Items in Gridview hides behind following items

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 484 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.
  • C Offline
    C Offline
    Cermit
    wrote on last edited by
    #1

    Hi, I need some help!

    I have a grid view with a random number of items. If I click on an item I want the item to change position and size (should be greater and moving to the center of the application). I tried it with a ParentChange and made a little example to demonstrate my problem:

    main.qml
    @import QtQuick 2.2
    import QtQuick.Controls 1.1

    ApplicationWindow {
    id: main
    width: 1920; height: 1080
    visible: true
    //visibility: "FullScreen"
    color: "black"

     GridView {
         id: grid_view
         anchors.fill: parent
         anchors.centerIn: parent
         cellWidth: 300
         cellHeight: 300
    
         model: 9
         delegate: fileDelegate
    
         Component {
             id: fileDelegate
             Rectangle {
                 width: grid_view.cellWidth; height: grid_view.cellHeight
                 radius: 20
                 color: "black"
                 TestElement {anchors.fill: parent}
             }
         }
     }
    
     Rectangle {
         id: main_view
         width: 1280; height: 720
         radius: 10
         color: "transparent"
         anchors.centerIn: parent
     }
    

    }
    @

    TestElement.qml
    @
    import QtQuick 2.2

    Item {
    id: container

    function randomBg(){
       var hex1=new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F")
       var hex2=new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F")
       var hex3=new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F")
       var hex4=new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F")
       var hex5=new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F")
       var hex6=new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F")
       var bg="#"+hex1[Math.floor(Math.random()*hex1.length)]+hex2[Math.floor(Math.random()*hex2.length)]+hex3[Math.floor(Math.random()*hex3.length)]+hex4[Math.floor(Math.random()*hex4.length)]+hex5[Math.floor(Math.random()*hex5.length)]+hex6[Math.floor(Math.random()*hex6.length)]
       return bg
    }
    
    Rectangle {
        id: rect
        width: parent.width; height: parent.height; radius: 20
        property bool maximized: false
        color: randomBg()
    
        MouseArea {
            id: playArea
            anchors.fill: parent
            onClicked: rect.maximized = !rect.maximized
        }
    
        states: State {
            name: "maximized"
            when: rect.maximized
            
            ParentChange {
                target: rect
                parent: main_view
                x: 0; y: 0;
                width: parent.width; height: parent.height
            }
            PropertyChanges {target: rect; radius:0}
        }
    
        transitions: Transition {
            from: "*"
            to: "maximized"
            reversible: true
            ParentAnimation {
                PropertyAnimation {
                    target: rect
                    properties: "x,y,width,height"
                    easing.type: "InOutQuad"; duration: 1000
                }
            }
        }
    }
    

    }
    @

    The animation for maximizing works fine but when the transition is reversed, the rectangle hides behind his following items in the grid view. I tried to change the z-value but this didn't help!

    Thanks for your help!
    Cermit

    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