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. Elide of tab title in TabView
Forum Updated to NodeBB v4.3 + New Features

Elide of tab title in TabView

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 3 Posters 1.6k Views 1 Watching
  • 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.
  • P Offline
    P Offline
    patiobarbecue
    wrote on last edited by
    #1

    I am newbie...

    Just tried to modify the Qt example "Qt Quick Controls - gallery" for my needs. Its Styles.qml comes with the following code, and I just added one line to define the "elide" property of Text, which turned out has no effect. Any suggestions?

    @ property Component tabViewStyle: TabViewStyle {
    tabOverlap: 16
    frameOverlap: 4
    tabsMovable: true

        frame: Rectangle {
            gradient: Gradient{
                GradientStop { color: "#e5e5e5" ; position: 0 }
                GradientStop { color: "#e0e0e0" ; position: 1 }
            }
            border.color: "#898989"
            Rectangle { anchors.fill: parent ; anchors.margins: 1 ; border.color: "white" ; color: "transparent" }
        }
        tab: Item {
            property int totalOverlap: tabOverlap * (control.count - 1)
            implicitWidth: Math.min ((styleData.availableWidth + totalOverlap)/control.count - 4, image.sourceSize.width)
            implicitHeight: image.sourceSize.height
            BorderImage {
                id: image
                anchors.fill: parent
                source: styleData.selected ? "../images/tab_selected.png" : "../images/tab.png"
                border.left: 30
                smooth: false
                border.right: 30
            }
            Text {
                text: styleData.title
                anchors.centerIn: parent
                elide: Text.ElideLeft  //---------------> my modification
            }
        }
        leftCorner: Item { implicitWidth: 12 }
    }@
    
    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      text: styleData.title - what is the size of this ? Is it multi-line ?
      Can you look at the following bug ?

      https://bugreports.qt-project.org/browse/QTBUG-31414?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jens
        wrote on last edited by
        #3

        The text elide mode has no effect unless you constrain the size of your text item. By default a Text item has the size it needs to show the text without elide. If you instead of anchors.center in your text item, set anchors.left and anchors.right to the parent, it will force the text item to elide.

        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