help for hover qml component
-
Hy. I want to hover with the mouse over the MouseArea of a dayDelegate from a qml calendar component and produce an action, but the code not work. Please help. Thanks.
the code is:
Calendar { id:februarie style: CalendarStyle { dayDelegate: Rectangle { id: ziFebruarie color: {(eventsDataBase.comparaData(styleData.date)) ? "yellow" : "white"} Label{ id: labelZiFebruarie anchors.centerIn: parent text: styleData.date.getDate() } MouseArea{ anchors.fill: parent width: styleData.hovered height: styleData.hovered hoverEnabled: true onEntered: { console.log("carul mic"); } } } } }
-
Hi @vicarod
I dont see any problem in the code you posted. What is not working ? -
@p3c0 when I hoover with the mouse over dayDelegate nothing happens to console, but if I replace the following code
onEntered: { console.log("carul mic"); }
with
onClicked: { if (mouse.button == Qt.RightButton) { console.log("carul mic"); } }
it works...Why ?
-
@vicarod Your earlier code works perfectly as it is. Is that the only code ? Is it contained in any other component ?
-
You have right. I have a component in code, that is ToolTip. If remove the component it works. Why that ?
import QtQuick 2.2 import QtQuick.Window 2.1 import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.2 import EventsDataBase 1.0 Window { id: window1 visible: true width: Screen.width height: Screen.height title: "calendar genial" property int anCurent: 2015 EventsDataBase { id: eventsDataBase } Grid { id: grid clip: false anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter columns: 4 rows:3 spacing:2 //februarie Calendar { id:februarie visibleYear: window1.anCurent visibleMonth: 1 width: Screen.width/4.5 property string dataMea ToolTip { id: nono1 width: 200 target: februarie text: februarie.dataMea.toString() } style: CalendarStyle { navigationBar: Rectangle { color: "#ffc816" height: ianuarie.height/7 id: barFebruary Label { id: textFebruarie text: "februarie" + "-" + cbAn.currentText anchors.centerIn: parent font.pixelSize: 22 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter fontSizeMode: Text.Fit anchors.verticalCenter: parent.verticalCenter anchors.leftMargin: 2 anchors.rightMargin: 2 } } dayDelegate: Rectangle { id: ziFebruarie color: {(eventsDataBase.comparaData(styleData.date)) ? "yellow" : "white"} Label{ id: labelZiFebruarie anchors.centerIn: parent text: styleData.date.getDate() } MouseArea{ //http://stackoverflow.com/questions/26701710/qml-calendar-example-calendar-loses-ability-to-alter-selection-when-custom-mou anchors.fill: parent width: styleData.hovered height: styleData.hovered hoverEnabled: true anchors.centerIn: parent acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton onEntered: { console.log("carul mic"); februarie.dataMea = styleData.date; } } } } } } }