(Sloved) Change tab title in TabView



  • Hello guys :-)
    I want to change the current tab title in TabView but I can't access to tabs title propertie :(
    I have to add new tab by button with id : "btn_add_new" so I need to change current tab title by "btn_change_title" button.

    this is my code :

    TabView {
        id : mytab
        x: 22
        y: 43
        width: 576
        height: 209
    
    }
    
    Button {
        id: btn_change_title
        x: 261
        y: 258
        width: 166
        height: 23
        text: qsTr("Chnage current tab name")
    
        onClicked: {
    
            // Change the current tab Title
            //Can't access to current tab (title) 
           mytab.title = "New tab Title"
    
        }
    }
    
    Button {
        id: btn_add_new
        x: 180
        y: 258
        text: qsTr("Add new tab")
    
        onClicked: {
    
            ts.addTab("My tab");
    
        }
    }

  • Moderators

    @EmulationQt Use getTab to get tab at particular index and then access its title

    mytab.getTab(0).title = "New tab Title"
    


  • @p3c0 said:

    @EmulationQt Use getTab to get tab at particular index and then access its title

    mytab.getTab(0).title = "New tab Title"
    

    Thank you @p3c0 :-)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.