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. QML Window implicit size based on component and property changes

QML Window implicit size based on component and property changes

Scheduled Pinned Locked Moved QML and Qt Quick
windowimplicit size
1 Posts 1 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.
  • T Offline
    T Offline
    Thibaut D.
    wrote on last edited by Thibaut D.
    #1

    Having the following QML file; it works correctly. The window resize according to mainLayout implicit size. The problem is that inside mainLayout, I have two mutually exclusive components.

    One is shown when connectionManager.connected == true and the other one when it's false. When the connected attribute changes, I think the following is happening:

    1. Hide the element that need to be hidden according to "connected" value
    2. Resize the window according to mainLayout size (which is almost 0 because the content of the layout is not visible)
    3. Displays the element that need to be according to "connected" value.
    4. Resize the window according to mainLayout size (which is correct).

    The problem is that my window is resized to an invalid geometry. This makes the window blink, and displays an error message in QML. Even if the behavior is correct, it's not visually good.

    Do somebody knows how to avoid this behavior ?

    import QtQuick 2.4
    import QtQuick.Extras 1.4
    import QtQuick.Controls 1.4
    import QtQuick.Window 2.2
    import QtQuick.Layouts 1.2
    import QtQuick.Controls.Styles 1.2
    
    ApplicationWindow {
    
        visible: true
    
        width: mainLayout.implicitWidth + 40
        height: mainLayout.implicitHeight + 40
    
        ConnectionManager {
            id: connectionManager
            pluginsDirectory: "Plugins"
        }
    
        ColumnLayout {
            id: mainLayout
            anchors.centerIn: parent
            ConnectionBox {
                id: box
                manager: connectionManager
                visible: !connectionManager.connected
            }
            ColumnLayout {
                visible: connectionManager.connected
                spacing: 10
                GridLayout {
                    columns: 2
                    columnSpacing: 15
                    rowSpacing: 15
                    Button {
                        text: "Test Command"
                    }
                    Button {
                        text: "Disconnect"
                        onClicked: connectionManager.closeConnection()
                    }
                }
                TextArea {
                    Layout.topMargin: 10
                    Layout.preferredHeight: 300
                    Layout.preferredWidth: 300
                    readOnly: true
                }
            }
        }
    }
    
    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