QML Tooltip issue when backend data are being updated
Unsolved
QML and Qt Quick
-
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?
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) } } } } }