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. Auto-resize tabs to fit content in TabView
Forum Updated to NodeBB v4.3 + New Features

Auto-resize tabs to fit content in TabView

Scheduled Pinned Locked Moved 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.
  • P Offline
    P Offline
    petro.popov
    wrote on last edited by
    #1

    I am trying to create a TabView control with some content inside. The problem is that tab does not get re-sized to fit all the content. As the result the last label in the following example goes out from the tab border.
    @
    import QtQuick 2.1
    import QtQuick.Controls 1.1
    import QtQuick.Layouts 1.0

    ApplicationWindow {
    title: "Hello World"
    visible: true
    width: 640
    height: 480

    TabView {
        Tab {
            title: "Tab 1"            
            ColumnLayout
            {                    
                spacing: 5
                Label {text: "Label 1"}
                Label {text: "Label 2"}
                Label {text: "Label 3"}
                Label {text: "Label 4"}
                Label {text: "Label 5"}
                Label {text: "Label 6"}
            }           
        }
    }
    

    }
    @

    This is how it looks:
    !http://s18.postimg.org/3xpyaxe8p/qml_tab_view.png(Example)!

    Thanks in advance!

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dasRicardo
      wrote on last edited by
      #2

      Hmmm maybe it's better to add a flickable container to the tab and add the content to the flickable container. I mean in qml a parent can change the size of the childs (anchors) but doesn't work in the other direction.

      **Sorry for my english :)

      PLEASE ADD [SOLVED] TO YOUR THREAD TITLE IF IT'S SOLVED.**

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jens
        wrote on last edited by
        #3

        Yes this is indeed not a good idea. Remember that you have different content on each tab, so adjusting a tabs size to whatever is on the first tab is simply not a good idea. You can certainly hack this in place by binding size to the current tabs item but I would argue against doing this.

        You should rather just let the tab fill the parent size, and add a ScrollView in each tab if contents do not fit as dasRicardo suggested.

        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