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. Resize window to content
Forum Updated to NodeBB v4.3 + New Features

Resize window to content

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

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

    1 Reply Last reply
    1
    • KillerSmathK Offline
      KillerSmathK Offline
      KillerSmath
      wrote on last edited by KillerSmath
      #2

      @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
          }
      }
      

      @Computer Science Student - Brazil
      Web Developer and Researcher
      “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

      RokeJulianLockhartR 1 Reply Last reply
      1
      • KillerSmathK KillerSmath

        @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
            }
        }
        
        RokeJulianLockhartR Offline
        RokeJulianLockhartR Offline
        RokeJulianLockhart
        wrote on last edited by RokeJulianLockhart
        #3

        @KillerSmath, it doesn't for me (versionlessly):

        6c95d923-3b21-4c5e-b878-2dcceb1d196b-Screenshot_20250819_125423.png

        If it did, I doubt that stackoverflow.com/questions/45066601 would have been asked (I doubt it's a failure of my compositor).

        When using a forum, remember to tag the person you are responding to, in case they are not subscribed to the thread.

        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