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. Remove space between TabButton in TabBar
Qt 6.11 is out! See what's new in the release blog

Remove space between TabButton in TabBar

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 3 Posters 708 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.
  • E Offline
    E Offline
    efdiloreto
    wrote on last edited by
    #1

    How to remove the white space between the buttons? i can't find the correct property...

    alt text

    This is my code:

    Boton.qml:

    TabButton {
        onCheckedChanged: canvas.requestPaint()
    
        contentItem: Text {
            antialiasing: false
            text: parent.text
            font.family: "monofonto"
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            color: "#19F51E"
        }
        background: Rectangle{
            color: 'black'
        }
        Canvas{
            id: canvas
            width: parent.width
            height: parent.height
            onPaint: {
                var ctx = getContext("2d");
                ctx.reset()
                ctx.lineWidth = 5;
                ctx.strokeStyle = "#19F51E";
                ctx.beginPath()
                if (parent.checked){
                    ctx.moveTo(0, 0)
                    ctx.lineTo(width, 0)
                } else {
                    ctx.moveTo(0, height)
                    ctx.lineTo(width, height)
                }
                ctx.stroke()
            }
        }
    }
    

    Main.qml:

    
    Window{
        color: 'black'
    TabBar {
        width: parent.width
        anchors.margins: 0
        Boton {
            text: "BUTTON"
        }
        Boton {
            text: "BUTTON"
        }
        Boton {
            text: "BUTTON"
        }
    }
    
    StackLayout {
        width: parent.width
        currentIndex: bar.currentIndex
        Item {
            id: homeTab
        }
        Item {
            id: discoverTab
        }
        Item {
            id: activityTab
        }
    }
    }
    
    
    1 Reply Last reply
    0
    • IntruderExcluderI Offline
      IntruderExcluderI Offline
      IntruderExcluder
      wrote on last edited by
      #3

      Set spacing property to 0.

      E 1 Reply Last reply
      2
      • MarkkyboyM Offline
        MarkkyboyM Offline
        Markkyboy
        wrote on last edited by
        #2
        This post is deleted!
        1 Reply Last reply
        0
        • IntruderExcluderI Offline
          IntruderExcluderI Offline
          IntruderExcluder
          wrote on last edited by
          #3

          Set spacing property to 0.

          E 1 Reply Last reply
          2
          • IntruderExcluderI IntruderExcluder

            Set spacing property to 0.

            E Offline
            E Offline
            efdiloreto
            wrote on last edited by
            #4

            @IntruderExcluder

            Thanks! that works.

            1 Reply Last reply
            0

            • Login

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