<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[tabview with dynamic tabs]]></title><description><![CDATA[<p dir="auto">Hi friends,</p>
<p dir="auto">I am trying to create tabview with tabs like browser in qml.I have written below code</p>
<p dir="auto">import QtQuick 2.0<br />
import QtQuick 2.2<br />
import QtQuick.Controls 1.1<br />
import QtQuick.Layouts 1.1<br />
import QtQuick.Controls 2.2<br />
import QtQuick.Controls 2.15<br />
import QtQuick 2.5<br />
import QtQuick.Window 2.2<br />
import QtQuick.Dialogs 1.3<br />
import QtQuick.Controls.Styles 1.1<br />
import QtQuick.Controls 1.2</p>
<p dir="auto">Rectangle<br />
{<br />
id:tabViewgui<br />
color:  "gray"<br />
border.color: "black"<br />
border.width: 5<br />
radius: 8<br />
visible: true</p>
<pre><code>Dialog
{
    id: errorDialog
    title: "Yazmi"
    width: 300

    ColumnLayout
    {
        Label
        {
            text: qsTr("More than 10 tabs cannot be created.")
            font.pixelSize: 15
        }

    }
    standardButtons: StandardButton.Ok
}


TabView
{
    id: tabView
    anchors.margins: 2
    visible: false
    anchors.fill: parent
    style: TabViewStyle
    {
        property color frameColor: "#484848"
        property color fillColor: "#484848"

        tab: Rectangle
        {
            color: styleData.selected ? fillColor : frameColor
            implicitWidth: Math.max(text.width + 45, 80)
            implicitHeight: 35
            border.color: "black"
            border.width:1.5
            radius: 8

            Text
            {
                id: text
                anchors.left: parent.left
                anchors.verticalCenter: parent.verticalCenter
                anchors.leftMargin: 6
                text: styleData.title
                color: styleData.selected ? "white" : "white"
                font.pixelSize: 15

            }
            ToolButton
            {
                anchors.right: parent.right
                anchors.verticalCenter: parent.verticalCenter
                anchors.rightMargin: 4
                implicitWidth: 30
                implicitHeight: 30
                iconSource: "qrc:/images/close2.png"

                onClicked:
                {
                    onClicked: tabView.removeTab(styleData.index)
                    addbutn.x = (addbutn.x - tabView.implicitWidth/2)
                }
            }


        }

    }
}
ToolButton
{
    id:addbutn
    iconSource: "qrc:/images/Add2.png"
    antialiasing: true
    x:0
    y:0
    //anchors.fill:parent
    onClicked:
    {
        console.log("addbutn clicked")

        tabView.visible = true
        if(tabView.count &lt; 10)
        {
            var c = Qt.createComponent("Paintview.qml");
            tabView.addTab("WhiteBoard",c);
            var last = tabView.count-1;
            tabView.getTab(last).active = true; // Now the content will be loaded
            addbutn.x = tabView.count*(tabView.implicitWidth/2)
            console.log("addbutn X Position :",addbutn.x,anchors.leftMargin,tabView.count)
        }
        else
        {
            errorDialog.open()
        }

    }
}
</code></pre>
<p dir="auto">}</p>
<p dir="auto">In this  when in click on ToolButton it is not working.<br />
when i enable this line in code         <a href="//anchors.fill" target="_blank" rel="noopener noreferrer nofollow ugc">//anchors.fill</a>:parent<br />
it is working but I cannot put x and y pos to zero.<br />
Can anybody tell problem and how to solve.</p>
]]></description><link>https://forum.qt.io/topic/128118/tabview-with-dynamic-tabs</link><generator>RSS for Node</generator><lastBuildDate>Fri, 25 Sep 2026 15:11:36 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/128118.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 02 Jul 2021 08:41:41 GMT</pubDate><ttl>60</ttl></channel></rss>