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. How to - Customization of TabButton - Qt 5.7 - Qt Quick Controls 2 - Material -
QtWS25 Last Chance

How to - Customization of TabButton - Qt 5.7 - Qt Quick Controls 2 - Material -

Scheduled Pinned Locked Moved Solved QML and Qt Quick
material designcustomizeqt 5.7qt quickcontrols 2
3 Posts 2 Posters 4.7k 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.
  • _ Offline
    _ Offline
    _Michel
    wrote on last edited by
    #1

    Hi,

    I'm playing with the new Qt 5.7 Qt Quick Controls 2 with Material style.

    I have a TabBar as the header of my ApplicationWindow.
    I'm trying to customize the TabButtons. The documentation says : TabButton can be customized in the same manner as Button.
    So, I look at Customizing Button and apply the same to my TabButton :

                TabButton {
                    width: 100
                    text: "Entry"
                    contentItem: Text {
                              text: control.text
                              font: control.font
                              opacity: enabled ? 1.0 : 0.3
                              color: control.down ? "#17a81a" : "#21be2b"
                              horizontalAlignment: Text.AlignHCenter
                              verticalAlignment: Text.AlignVCenter
                              elide: Text.ElideRight
                          }
                }
    

    It doesn't work, QML Material widgets seem to be different, control is not defined.

    qrc:/main.qml:66: ReferenceError: control is not defined
    
    Julien BJ 1 Reply Last reply
    0
    • _ _Michel

      Hi,

      I'm playing with the new Qt 5.7 Qt Quick Controls 2 with Material style.

      I have a TabBar as the header of my ApplicationWindow.
      I'm trying to customize the TabButtons. The documentation says : TabButton can be customized in the same manner as Button.
      So, I look at Customizing Button and apply the same to my TabButton :

                  TabButton {
                      width: 100
                      text: "Entry"
                      contentItem: Text {
                                text: control.text
                                font: control.font
                                opacity: enabled ? 1.0 : 0.3
                                color: control.down ? "#17a81a" : "#21be2b"
                                horizontalAlignment: Text.AlignHCenter
                                verticalAlignment: Text.AlignVCenter
                                elide: Text.ElideRight
                            }
                  }
      

      It doesn't work, QML Material widgets seem to be different, control is not defined.

      qrc:/main.qml:66: ReferenceError: control is not defined
      
      Julien BJ Offline
      Julien BJ Offline
      Julien B
      wrote on last edited by
      #2

      Hello @_Michel,

      control is an id try adding id: control on your TabButton.

      1 Reply Last reply
      1
      • _ Offline
        _ Offline
        _Michel
        wrote on last edited by
        #3

        ...
        OK, this works. I thought that control was a reserved keyword.

        <u>For readers :</u>
        Since I have many TabButton, I don't use id: control as suggested but parent.

                    TabButton {
                        id: tabButtonMenu
                        width: 100
                        height: parent.height
                        text: "Menu"
                        contentItem: Text {
                            text: parent.text
                            font: parent.font
                            opacity: enabled ? 1.0 : 0.3
                            color: parent.down ? "yellow" : "white"
                            horizontalAlignment: Text.AlignHCenter
                            verticalAlignment: Text.AlignVCenter
                            elide: Text.ElideRight
                        }
                    }
        
        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved