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. TabBar implicit width and height within a layout?

TabBar implicit width and height within a layout?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 84 Views
  • 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.
  • B Offline
    B Offline
    bvanheu
    wrote on last edited by bvanheu
    #1

    Hi,

    I'm wondering why the TabBar in the following code seems to set the implicit width and height of the element in the layout. I would have expected the orange rectangle to be the same width of rectangle 2 and 3, and the same height as rectangle 4.

    Why is rectangle "1-a" so big?

    I'm using QT 6.10.1 on Linux / Desktop.

    import QtQuick
    import QtQuick.Controls
    import QtQuick.Layouts
    
    ApplicationWindow {
        width: 640
        height: 480
        visible: true
        title: qsTr("Hello World")
    
        ColumnLayout {
            anchors.fill: parent
            RowLayout {
                ColumnLayout {
                    TabBar {
                        id: projectTabBar
                        TabButton {
                            text: "a"
                        }
                        TabButton {
                            text: "b"
                        }
                        TabButton {
                            text: "c"
                        }
                    }
                    StackLayout {
                        currentIndex: projectTabBar.currentIndex
                        Rectangle {
                            color: "orange"
                            Text {
                                text: "1 - a"
                                anchors.centerIn: parent
                            }
                        }
                        Rectangle {
                            color: "red"
                            Text {
                                text: "1 - b"
                                anchors.centerIn: parent
                            }
                        }
                    }
                }
                Rectangle {
                    color: "yellow"
                    Layout.fillWidth: true
                    Layout.fillHeight: true
                    Text {
                        text: "2"
                        anchors.centerIn: parent
                    }
                }
                Rectangle {
                    color: "cyan"
                    Layout.fillWidth: true
                    Layout.fillHeight: true
                    Text {
                        text: "3"
                        anchors.centerIn: parent
                    }
                }
            }
            Rectangle {
                Layout.fillHeight: true
                Layout.fillWidth: true
                color: "black"
                Text {
                    text: "4"
                    anchors.centerIn: parent
                    color: "white"
                }
            }
        }
    }
    

    Screenshot:

    20251216_23h15m47s_grim.png

    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