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. QML Tooltip issue when backend data are being updated
Forum Updated to NodeBB v4.3 + New Features

QML Tooltip issue when backend data are being updated

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 109 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.
  • N Offline
    N Offline
    nsourl
    wrote on 15 Oct 2022, 20:23 last edited by
    #1

    Hi,

    I have created a TableView and the third column is marked as an "error" column. So, when clicking on the MouseArea of each Label in the third column, I would like to show a ToolTip with some information about the system errors.

    Αlthough the first time everything works as expected (image 1) when the ToolTip is still open and meanwhile the data on the backend (QAbstractTableModel) are being updated, the ToolTip loses its initial position (image 2). The source code is attached below to see how I handle the TableView and the TooTip.

    Any idea why this is happening and how it could be resolved?

    tooltip_ok.png

    tooltip_issue.png

    TableView {
        id: tableView
        
        property var columnWidths: [30, 50, 50, 40, 50, 55, 60, 40, 60, 60, 50, 45, 65, 65, 50, 50, 50, 65, 65]
        columnWidthProvider: function (column) { return columnWidths[column]; }
        rowHeightProvider: function (column) { return 50; }
        anchors.fill: parent
        anchors.margins: 0
        topMargin: columnsHeader.implicitHeight
        model: _TrackerMatrixModel
        boundsBehavior: Flickable.StopAtBounds
        ScrollBar.horizontal: ScrollBar{}
        ScrollBar.vertical: ScrollBar{}
        clip: true
        
        delegate: Rectangle {
            
            // Identify the column which is related to errors
            property bool isErrorCol: (column === 3) ? true : false
            property bool isEmptyCol: (display === "-") ? true : false
            color: (row % 2 === 0) ? Material.backgroundColor : "#333333"
            
            Label {
                id: trlbl
                text: isErrorCol ? (isEmptyCol ? "\uf058" : "\uf071") : display
                anchors.fill: parent
                anchors.margins: 10
                color: isErrorCol ? (isEmptyCol ? "#31a72c" : "#FDDA16") : "#67CBE4"
                font.pointSize: isErrorCol ? 20 : 11
                horizontalAlignment: Text.AlignHCenter
                verticalAlignment: Text.AlignVCenter
                
                ToolTip {
                    id: customTooltip
                    width: 300
                }
                
                MouseArea {
                    id: ma
                    anchors.fill: parent
                    enabled: isErrorCol
                    hoverEnabled: isErrorCol
                    
                    property string toolTipText: (display === "-") ? "No Errors" : display
                    
                    onClicked: {
                        customTooltip.x = ma.x + 40
                        customTooltip.y = ma.y
                        customTooltip.show(toolTipText)
                    }
                }
            }
        }
    }
    
    1 Reply Last reply
    0

    1/1

    15 Oct 2022, 20:23

    • Login

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