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. help for hover qml component
Forum Updated to NodeBB v4.3 + New Features

help for hover qml component

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 2.8k Views 2 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.
  • V Offline
    V Offline
    vicarod
    wrote on last edited by
    #1

    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");
                    }
                }
    
            }
    
    
        }
    
    }
    
    p3c0P 1 Reply Last reply
    0
    • V vicarod

      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");
                      }
                  }
      
              }
      
      
          }
      
      }
      
      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi @vicarod
      I dont see any problem in the code you posted. What is not working ?

      157

      V 1 Reply Last reply
      0
      • p3c0P p3c0

        Hi @vicarod
        I dont see any problem in the code you posted. What is not working ?

        V Offline
        V Offline
        vicarod
        wrote on last edited by
        #3

        @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 ?

        p3c0P 1 Reply Last reply
        0
        • V vicarod

          @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 ?

          p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          @vicarod Your earlier code works perfectly as it is. Is that the only code ? Is it contained in any other component ?

          157

          1 Reply Last reply
          0
          • V Offline
            V Offline
            vicarod
            wrote on last edited by vicarod
            #5

            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;
            
                            }
            
            
                        }
            
                    }
            
                }
            
                    }
            
                }
            
            }
            
            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