Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-128520

Menu QML type deprecated use of mouse parameter

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Fixed
    • Not Evaluated
    • 6.9.0 FF
    • 6.7.0
    • GUI: Menus
    • None
    • Since this is in the Qt documentation this is visible everywhere.

    • All
    • a70ddf115 (dev)

    Description

      In the Qt documentation page for the qt quick controls menu type there is use of the parameter "mouse" injected to the signal handler:

      onClicked: {
              if (mouse.button === Qt.RightButton)
                  contextMenu.popup()
          }
          onPressAndHold: {
              if (mouse.source === Qt.MouseEventNotSynthesized)
                  contextMenu.popup()
          } 

      Even when you run code you get a qt.qml.context compiler message:
      Parameter "mouse" is not declared. Injection of parameters into signal handlers is deprecated. Use JavaScript functions with formal parameters instead.

      It can be solved by using simple lambda :

      onClicked: (mouse) => {
              if (mouse.button === Qt.RightButton)
                  contextMenu.popup()
          }
          onPressAndHold: (mouse) => {
              if (mouse.source === Qt.MouseEventNotSynthesized)
                  contextMenu.popup()
          } 

       

      Attachments

        For Gerrit Dashboard: QTBUG-128520
        # Subject Branch Project Status CR V

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            dizarc Faruk Yildiz
            Qt Documentation Team Qt Documentation Team
            Qt Documentation Team Qt Documentation Team
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes