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. TableViewColumn: resizing header width doesn't adjust column contents with "..."

TableViewColumn: resizing header width doesn't adjust column contents with "..."

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 312 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.
  • J Offline
    J Offline
    jimbolaya
    wrote on last edited by
    #1

    Hey all,

    I'm using the following TableView Example:

    ListModel {
            id: libraryModel
            ListElement {
                title: "A Masterpiece"
                author: "Gabriel"
            }
            ListElement {
                title: "Brilliance"
                author: "Jens"
            }
            ListElement {
                title: "Outstanding"
                author: "Frederik"
            }
        }
    
        C.TableView {
            id: asdf
            width: parent.width
            anchors.topMargin: 5;
            alternatingRowColors: false
            horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
            verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff
            frameVisible: false;
            rowDelegate: rowDelegate
            C.TableViewColumn {
                role: "title"
                title: "Title"
                width: 100
                delegate: columnDelegate
            }
            C.TableViewColumn {
                role: "author"
                title: "Author"
                width: 200
            }
            model: libraryModel
        }
    

    So when resizing the author column so that the contents wouldn't fit, the contents automatically append a "...". However, when I apply a delegate such as to the Title column, it loses that functionality. Any way of modifying the delegate to have it behave it so that when resizing the column, it would append a "..." if content doesn't fit?

    Here is my delegate code:

    Component {
            id: columnDelegate
            TextEdit {
                color: styleData.selected ? "white" : "black"
                font.bold: false
                font.weight: Font.ExtraLight
                font.pointSize: 10
                leftPadding: 10
                readOnly: true
                selectByMouse: false
                text: styleData.value
                verticalAlignment: TextEdit.AlignBottom
                persistentSelection: false
                onActiveFocusChanged: {
                    if (activeFocus === false) {
                        deselect();
                    } else {
                        selectAll();
                    }
                }
                MouseArea {
                    anchors.fill: parent
                    onClicked: {
                        parent.forceActiveFocus();
                    }
                }
            }
        }
    

    Here's a screenshot of how it looks with the two columns.
    0_1542749151396_Capture.PNG

    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