Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Resize window to content



  • Is there any easy way to automatically adjust the window size to fit the content (text, it's a message dialog)?



  • @AlexP11223

    ApplicationWindow performs auto resize to fit their children

    import QtQuick 2.11
    import QtQuick.Controls 1.4
    
    ApplicationWindow {
        id: window
        visible: true
        title: "My Window Title"
    
        Rectangle{
            id: rect1
            color: "#ff00ff"
            width:360; height: 50
        }
    
        Rectangle{
            id: rect2
            color: "#ff0000"
            anchors {top: rect1.bottom; left: rect1.left}
            width: 280; height: 280
        }
    
        Rectangle{
            id: rect3
            color: "#ffff00"
            anchors {left: rect2.right; top: rect1.bottom}
            width: 120; height: 150
        }
    }
    

Log in to reply