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. Bounding rectangle of rotated Item

Bounding rectangle of rotated Item

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 1.2k 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
    MattB.au
    wrote on last edited by
    #1

    How do you access the bounding rectangle of a rotated QML Item? For example in the code below how would I make the parent 'boundingRect' match the extents of the rotated child.

    @
    import QtQuick 2.1
    import QtQuick.Controls 1.0

    ApplicationWindow {
    id: mainWindow
    width: 300
    height: 300

    Rectangle {
    
        id: boundingRect
        x: 50
        y: 50
        color: 'yellow'
    
        width: childrenRect.width
        height: childrenRect.height
    
        Rectangle {
            id: rotated
            width: 75
            height: 100
            border.width: 1
            border.color: 'blue'
            rotation: 45
        }
    }
    

    }
    @

    Started to look at a solution using a width/height based on mapFromItem() but I don't think that's going to work as a general solution when I have multiple children which may be rotated and I want the bounding box of all of them.

    Thanks

    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