qtraspberry-piqml

QML: Hover doesn't work on raspberry pi 4b


I use QML for Raspberry pi program with interface. And when I start my program as local user - hover doesn't work. When like root user - It's all Ok with hover, but there is a different in UI. How can i use local user with hover?

Code example with, where button.hovered not true all the times.

import QtQuick 2.15
import QtQuick.Controls 2.15 as Control
import QtQuick.Layouts 1.15

Control.Button {
    id: button

    property alias textObj: _text
    property alias txt: item_metrics_first.text
    property string borderColor: "#69ccff"
    property string backgroundColor: "#025b97"
    property string textColor: "white"
    property string activeColor: "#014a7d"

    background: Rectangle {
            opacity: enabled ? 1 : 0.3
            Text{
                id: _text
                text: item_metrics_first.elidedText
                anchors.fill: parent
                font.family: "Din Pro Black"
                color: button.down ? activeColor: (button.hovered ? borderColor: textColor)
                horizontalAlignment: Text.AlignHCenter
                verticalAlignment: Text.AlignVCenter
            }
            TextMetrics {
                    id:     item_metrics_first
                    font:   _text.font
                    elideWidth: button.width - 10
                    elide: Text.ElideMiddle
                }
            color: button.down ? borderColor: backgroundColor
            border.color: button.down ? activeColor: (borderColor)
            border.width: 2
            radius: 5
        }
}

ls -l /dev/input shows

drwxr-xr-x 2 root root     120 Oct 13 13:31 by-id
drwxr-xr-x 2 root root     160 Oct 13 13:31 by-path
crw-rw---- 1 root input 13, 64 Oct 13 13:31 event0
crw-rw---- 1 root input 13, 65 Oct 13 13:25 event1
crw-rw---- 1 root input 13, 66 Oct 13 13:25 event2
crw-rw---- 1 root input 13, 67 Oct 13 13:25 event3
crw-rw---- 1 root input 13, 68 Oct 13 13:25 event4
crw-rw---- 1 root input 13, 69 Oct 13 13:25 event5
crw-rw---- 1 root input 13, 70 Oct 13 13:26 event6
crw-rw---- 1 root input 13, 71 Oct 13 13:26 event7
crw-rw---- 1 root input 13, 63 Oct 13 13:25 mice
crw-rw---- 1 root input 13, 32 Oct 13 13:31 mouse0`

and my local user is in "input" group.

evtest with local user works.


Solution

  • hoverEnabled: true - it is help me