Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1573

Cannot use MouseEvent

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • 6.2.0
    • 6.1.0
    • PySide
    • None
    • Windows 10
    • Linux/X11, Windows

    Description

      The QML application will not start if I try to use a MouseEvent under PySide6. Minimal example:

       

      main.qml

      import QtQuick
      import QtQuick.Window
      
      Window {
          width: 640
          height: 480
          visible: true
      
          MouseArea {
              anchors.fill: parent
              onWheel: console.log(wheel.angleDelta)
          }
      }
      

      main.py

      import sys
      import os
      
      import PySide6.QtCore as QtCore
      from PySide6.QtGui import QGuiApplication
      from PySide6.QtQml import QQmlApplicationEngine
      
      def qt_message_handler(mode, context, message):
          if mode == QtCore.QtInfoMsg:
              mode = 'INFO'
          elif mode == QtCore.QtWarningMsg:
              mode = 'WARNING'
          elif mode == QtCore.QtCriticalMsg:
              mode = 'CRITICAL'
          elif mode == QtCore.QtFatalMsg:
              mode = 'FATAL'
          else:
              mode = 'DEBUG'
          print('qt_message_handler: line: %d, func: %s(), file: %s' % (
              context.line, context.function, context.file))
          print('  %s: %s\n' % (mode, message))
      
      
      if __name__ == "__main__":
          QtCore.qInstallMessageHandler(qt_message_handler)
          app = QGuiApplication(sys.argv)
          engine = QQmlApplicationEngine()
          engine.load(os.path.join(os.path.dirname(__file__), "main.qml"))
      
          if not engine.rootObjects():
              sys.exit(-1)
          sys.exit(app.exec())
      

      If I change to PySide2 and add version numbers to the qml imports, the application starts and logs fine.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            jirauser60745 user-fdd67 (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes