Important: Please read the Qt Code of Conduct -

QML TabBar bunch up when not visible?

  • I have a TabBar in QML which has 3 tabs, one of the tabs, the one in the middle is only visible when the application is connected to another device.

    The issue is that whilst the tab's visible property works and the tab is visible or hidden when its connected or not connected, the space that the tab occupies in the tabbar is still reserved.

    Is there anyway to bunch up or move the tabs after this one so there isn't a space? Of course I could re-order them but I would rather show a nice animation of the tabs moving when they are or are not visible.

  • Moderators

    hi @SPlatten

    I haven't used QML TabBar yet, but if it behaves like other QMl objects, you could tie the width to the visibility of the tab. Make its with 0 when not visible and x when visible

    That way you can also easily add animation via Behavior on width { NumberAnimation {...}}

  • Presently the width is not set I think its worked out from the text, I will play around and see if I can use empty text if not visible.

    So far that did nothing, it seems the tabbar occupies the space available to it. I just found information on a TabView which looks different in the way its rendered it doesn't use the full width and tabs are sized dynamically, I'l give that a try.

    Dammit!!! According to the page I just read:

    It should be available, my QML page starts with this:

        import QtQuick 2.7
        import QtQuick.Controls 2.1
        import QtQuick.Controls.Styles 1.4
        import QtQuick.Layouts 1.3
        import QtGraphicalEffects 1.0

    The version of Qt it 5.8, I have no control over that, but according to the link I posted tabview should be available from Qt 5.1 with QtQuick.Controls 1.4

    So why when I type in TabView is it underlined in red with "Unknonwn component. (M300)" ?

    Just found this:

    Checked "Enable Qt Quick Compiler", this triggered a Build, didn't help same "Unknown component. (M300)".

Log in to reply