Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QGestureRecognizer.registerRecognizer() crashes using PySide2
Forum Updated to NodeBB v4.3 + New Features

QGestureRecognizer.registerRecognizer() crashes using PySide2

Scheduled Pinned Locked Moved Unsolved Qt for Python
19 Posts 4 Posters 1.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.
  • jeremy_kJ jeremy_k

    PanGestureRecognizer doesn't have an __init__ to call QGestureRecognizer.__init__. I vaguely recall reports of misbehavior using PyQt if a Qt object's constructor isn't invoked. This may have been limited to QObjects. It might not apply to PySide. Either way, it's an inexpensive experiment to run. QGestureRecognizer's C++ constructor is empty, but there may be some bookkeeping on the Python side.

    N Offline
    N Offline
    nutrx
    wrote on last edited by
    #10

    @jeremy_k you mean, I should try just calling QGestureRecognizer's __init__ in PanGestureRecognizer.__init__? I would've guessed that's ambiguous, or does instanciation lead to a direct call of the C++ parent constructor instead of the parent's __init__ in Python? However, I just tried, still no luck :/

    jeremy_kJ 1 Reply Last reply
    0
    • N nutrx

      @jeremy_k you mean, I should try just calling QGestureRecognizer's __init__ in PanGestureRecognizer.__init__? I would've guessed that's ambiguous, or does instanciation lead to a direct call of the C++ parent constructor instead of the parent's __init__ in Python? However, I just tried, still no luck :/

      jeremy_kJ Offline
      jeremy_kJ Offline
      jeremy_k
      wrote on last edited by
      #11
      class PanGestureRecognizer(QGestureRecognizer):
          def __init__(self):
              super().__init__()
      

      This doesn't seem to be necessary with pure python classes. The wording of object.__init__ led me to believe that it was, but a test suggests that the base class __init__ is called if no derived __init__ is defined.

      Asking a question about code? http://eel.is/iso-c++/testcase/

      JonBJ 1 Reply Last reply
      0
      • jeremy_kJ jeremy_k
        class PanGestureRecognizer(QGestureRecognizer):
            def __init__(self):
                super().__init__()
        

        This doesn't seem to be necessary with pure python classes. The wording of object.__init__ led me to believe that it was, but a test suggests that the base class __init__ is called if no derived __init__ is defined.

        JonBJ Online
        JonBJ Online
        JonB
        wrote on last edited by JonB
        #12

        @jeremy_k
        Well, in Python just like in, say, C++, if you do not define your own __init__() (constructor in C++) the language will always cause the base class's __init__()/constructor. If you do define your own, you must then explicitly call the base class __init__()/constructor, in either language. in Python.

        [EDIT As @jeremy_k pointed out below, I was wrong to say this applies in all C++ cases. Let's leave it as: in Python, if you define any derived __init__() you must (should) explicitly call the base __init__() from there; but if you do not define a derived __init__() the base one will still be called.]

        I vaguely recall reports of misbehavior using PyQt if a Qt object's constructor isn't invoked

        I don't know if somehow PySide2/PyQt requires you to explicitly define your own __init__() and call the base, unless you have some reference for that?

        jeremy_kJ 1 Reply Last reply
        1
        • JonBJ JonB

          @jeremy_k
          Well, in Python just like in, say, C++, if you do not define your own __init__() (constructor in C++) the language will always cause the base class's __init__()/constructor. If you do define your own, you must then explicitly call the base class __init__()/constructor, in either language. in Python.

          [EDIT As @jeremy_k pointed out below, I was wrong to say this applies in all C++ cases. Let's leave it as: in Python, if you define any derived __init__() you must (should) explicitly call the base __init__() from there; but if you do not define a derived __init__() the base one will still be called.]

          I vaguely recall reports of misbehavior using PyQt if a Qt object's constructor isn't invoked

          I don't know if somehow PySide2/PyQt requires you to explicitly define your own __init__() and call the base, unless you have some reference for that?

          jeremy_kJ Offline
          jeremy_kJ Offline
          jeremy_k
          wrote on last edited by
          #13

          @JonB said in QGestureRecognizer.registerRecognizer() crashes using PySide2:

          @jeremy_k
          Well, in Python just like in, say, C++, if you do not define your own __init__() (constructor in C++) the language will always cause the base class's __init__()/constructor. If you do define your own, you must then explicitly call the base class __init__()/constructor, in either language.

          That's inaccurate for C++ base class default constructors. The compiler will insert a call to the base constructor if the programmer does not. Explicit invocation is only required if there are arguments to pass.

          Asking a question about code? http://eel.is/iso-c++/testcase/

          JonBJ 1 Reply Last reply
          1
          • jeremy_kJ jeremy_k

            @JonB said in QGestureRecognizer.registerRecognizer() crashes using PySide2:

            @jeremy_k
            Well, in Python just like in, say, C++, if you do not define your own __init__() (constructor in C++) the language will always cause the base class's __init__()/constructor. If you do define your own, you must then explicitly call the base class __init__()/constructor, in either language.

            That's inaccurate for C++ base class default constructors. The compiler will insert a call to the base constructor if the programmer does not. Explicit invocation is only required if there are arguments to pass.

            JonBJ Online
            JonBJ Online
            JonB
            wrote on last edited by
            #14

            @jeremy_k
            You are quite correct, and thank you for pointing this out. Partly I was unconsciously thinking of constructors with parameters, and partly I make slips as I swap between C#/C++/Python/JavaScript! I will correct my previous post, so as not to mislead.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #15

              You may have found a bug in the PySide2 implementation. Did you check if you have the same behaviour with PySide6 ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              N 1 Reply Last reply
              0
              • SGaistS SGaist

                You may have found a bug in the PySide2 implementation. Did you check if you have the same behaviour with PySide6 ?

                N Offline
                N Offline
                nutrx
                wrote on last edited by
                #16

                @SGaist yes, same with PySide6

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #17

                  Then you should go to the bug report system and see if there's already something there. If not, please consider opening a new issue providing your minimal runnable script that shows that behaviour.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • N Offline
                    N Offline
                    nutrx
                    wrote on last edited by nutrx
                    #18

                    Yeah, just found a bugreport reporting this exact issue. It's open since 2015..........
                    I am really confused. I mean ... isn't this making the whole custom gesture recognizer system completely unsuable?

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #19

                      It's an issue on Python and it has likely not been used that much with that language. You can add a comment on the issue to remind the current assigned person that this is still not solved.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      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