Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. PySide2 QMetaObject.invokeMethod() how to ?
QtWS25 Last Chance

PySide2 QMetaObject.invokeMethod() how to ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qapplicationqmetaobjectinvokemethod
8 Posts 2 Posters 1.6k Views
  • 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.
  • D Offline
    D Offline
    Dariusz
    wrote on 15 Jun 2020, 13:30 last edited by
    #1

    Hey

    How to properly execute this command in python :

    QMetaObject::InvokeMethod(qApp,[=](){doSomeStuff();},Qt::QueuedConnection)

    TIA ?

    J 1 Reply Last reply 15 Jun 2020, 14:44
    0
    • D Dariusz
      15 Jun 2020, 13:30

      Hey

      How to properly execute this command in python :

      QMetaObject::InvokeMethod(qApp,[=](){doSomeStuff();},Qt::QueuedConnection)

      TIA ?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 15 Jun 2020, 14:44 last edited by
      #2

      @Dariusz Like

      QMetaObject.invokeMethod(...)
      

      ?
      https://doc.qt.io/qtforpython/PySide2/QtCore/QMetaObject.html

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      D 1 Reply Last reply 16 Jun 2020, 13:14
      1
      • J jsulm
        15 Jun 2020, 14:44

        @Dariusz Like

        QMetaObject.invokeMethod(...)
        

        ?
        https://doc.qt.io/qtforpython/PySide2/QtCore/QMetaObject.html

        D Offline
        D Offline
        Dariusz
        wrote on 16 Jun 2020, 13:14 last edited by Dariusz
        #3

        @jsulm Hey, so would it be QMetaObject.InvokeMethod(QApplication.instance(), lambda (self.doSomeStuff()),Qt.QueuedConnection) ? Because all I get is lots of error I'm afraid...

        J 1 Reply Last reply 16 Jun 2020, 13:19
        0
        • D Dariusz
          16 Jun 2020, 13:14

          @jsulm Hey, so would it be QMetaObject.InvokeMethod(QApplication.instance(), lambda (self.doSomeStuff()),Qt.QueuedConnection) ? Because all I get is lots of error I'm afraid...

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 16 Jun 2020, 13:19 last edited by
          #4

          @Dariusz said in PySide2 QMetaObject.invokeMethod() how to ?:

          Because all I get is lots of error I'm afraid

          Which are?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          D 1 Reply Last reply 17 Jun 2020, 09:24
          0
          • J jsulm
            16 Jun 2020, 13:19

            @Dariusz said in PySide2 QMetaObject.invokeMethod() how to ?:

            Because all I get is lots of error I'm afraid

            Which are?

            D Offline
            D Offline
            Dariusz
            wrote on 17 Jun 2020, 09:24 last edited by Dariusz
            #5

            @jsulm

            TypeError: 'PySide2.QtCore.QMetaObject.invokeMethod' called with wrong argument types:
              PySide2.QtCore.QMetaObject.invokeMethod(QApplication, function, ConnectionType)
            Supported signatures:
              PySide2.QtCore.QMetaObject.invokeMethod(PySide2.QtCore.QObject, bytes, PySide2.QtCore.Qt.ConnectionType, PySide2.QtCore.QGenericReturnArgument, PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ...)
              PySide2.QtCore.QMetaObject.invokeMethod(PySide2.QtCore.QObject, bytes, PySide2.QtCore.QGenericReturnArgument, PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ...)
              PySide2.QtCore.QMetaObject.invokeMethod(PySide2.QtCore.QObject, bytes, PySide2.QtCore.Qt.ConnectionType, PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ...)
              PySide2.QtCore.QMetaObject.invokeMethod(PySide2.QtCore.QObject, bytes, PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ...)
            

            :- )

            J 1 Reply Last reply 17 Jun 2020, 10:46
            0
            • D Dariusz
              17 Jun 2020, 09:24

              @jsulm

              TypeError: 'PySide2.QtCore.QMetaObject.invokeMethod' called with wrong argument types:
                PySide2.QtCore.QMetaObject.invokeMethod(QApplication, function, ConnectionType)
              Supported signatures:
                PySide2.QtCore.QMetaObject.invokeMethod(PySide2.QtCore.QObject, bytes, PySide2.QtCore.Qt.ConnectionType, PySide2.QtCore.QGenericReturnArgument, PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ...)
                PySide2.QtCore.QMetaObject.invokeMethod(PySide2.QtCore.QObject, bytes, PySide2.QtCore.QGenericReturnArgument, PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ...)
                PySide2.QtCore.QMetaObject.invokeMethod(PySide2.QtCore.QObject, bytes, PySide2.QtCore.Qt.ConnectionType, PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ...)
                PySide2.QtCore.QMetaObject.invokeMethod(PySide2.QtCore.QObject, bytes, PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ...)
              

              :- )

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 17 Jun 2020, 10:46 last edited by
              #6

              @Dariusz Why do you want to call lambda using invokeMethod?
              As the name suggests invokeMethod is used to call a method of a class on an instance of that class. A lambda is not a method of QApplication...

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              D 1 Reply Last reply 17 Jun 2020, 13:12
              2
              • J jsulm
                17 Jun 2020, 10:46

                @Dariusz Why do you want to call lambda using invokeMethod?
                As the name suggests invokeMethod is used to call a method of a class on an instance of that class. A lambda is not a method of QApplication...

                D Offline
                D Offline
                Dariusz
                wrote on 17 Jun 2020, 13:12 last edited by
                #7

                @jsulm Well as the example in 1st post shows, I was creating a function in c++ to be called. I want the same to do in python. Simply put, I want to create temporary function that gets send to qapplication from 3rd party thread to be executed inside qt event loop.

                J 1 Reply Last reply 17 Jun 2020, 13:20
                0
                • D Dariusz
                  17 Jun 2020, 13:12

                  @jsulm Well as the example in 1st post shows, I was creating a function in c++ to be called. I want the same to do in python. Simply put, I want to create temporary function that gets send to qapplication from 3rd party thread to be executed inside qt event loop.

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 17 Jun 2020, 13:20 last edited by
                  #8

                  @Dariusz If you check the PySide documentation you will see that there is no overload taking a lambda or any function/method. There are only overloads accepting strings containing method name. So, it seems not possible with PySide.
                  But instead of using QApplication instance you could create your own class with methods you want to call using invokeMethod.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0

                  8/8

                  17 Jun 2020, 13:20

                  • Login

                  • Login or register to search.
                  8 out of 8
                  • First post
                    8/8
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved