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 last edited by
    #1

    Hey

    How to properly execute this command in python :

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

    TIA ?

    jsulmJ 1 Reply Last reply
    0
    • D Dariusz

      Hey

      How to properly execute this command in python :

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

      TIA ?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on 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
      1
      • jsulmJ jsulm

        @Dariusz Like

        QMetaObject.invokeMethod(...)
        

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

        D Offline
        D Offline
        Dariusz
        wrote on 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...

        jsulmJ 1 Reply Last reply
        0
        • D Dariusz

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

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on 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
          0
          • jsulmJ jsulm

            @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 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 = ...)
            

            :- )

            jsulmJ 1 Reply Last reply
            0
            • D Dariusz

              @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 = ...)
              

              :- )

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on 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
              2
              • jsulmJ jsulm

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

                jsulmJ 1 Reply Last reply
                0
                • D Dariusz

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

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 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

                  • Login

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