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 Align text centre in tab button?
Forum Updated to NodeBB v4.3 + New Features

How to Align text centre in tab button?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 4 Posters 1.2k 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.
  • S Offline
    S Offline
    Shankar B
    wrote on last edited by
    #1

    By default text should be aligned centre in tab button. But its displaying at top.

    jsulmJ 1 Reply Last reply
    0
    • S Shankar B

      By default text should be aligned centre in tab button. But its displaying at top.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Shankar-B said in How to Align text centre in tab button?:

      tab button

      What is "tab button"?
      Please explain more clearly what you want to do.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • S Offline
        S Offline
        Shankar B
        wrote on last edited by
        #3

        Am using tabbar component in qml. Inside tabbar am using tab button in which text is not getting centre aligned.

        JonBJ 1 Reply Last reply
        0
        • S Shankar B

          Am using tabbar component in qml. Inside tabbar am using tab button in which text is not getting centre aligned.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Shankar-B
          We would have had no idea you were asking about QML! Perhaps your question belongs better in https://forum.qt.io/category/12/qml-and-qt-quick

          J.HilkJ 1 Reply Last reply
          0
          • JonBJ JonB

            @Shankar-B
            We would have had no idea you were asking about QML! Perhaps your question belongs better in https://forum.qt.io/category/12/qml-and-qt-quick

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @JonB agreed, so moved.

            @Shankar-B

            you can customise it like any other Button element:
            https://doc.qt.io/qt-6/qtquickcontrols2-customize.html#customizing-button

            TabButton{
                    id: control
                    text: qsTr("TabButton")
            
                    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
                    }
                }
            

            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            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