Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Pyside, declarative: Returning a value from a slot
QtWS25 Last Chance

Pyside, declarative: Returning a value from a slot

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 4.3k 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.
  • A Offline
    A Offline
    adhorn
    wrote on last edited by
    #1

    Hi,

    Been playing with python/QML and slots returning values, but things dont seem to work well when you do something like:

    @
    class Communicate(QtCore.QObject):
    def init(self):
    super(Communicate,self).init()
    self.r = 0
    self.s = "heloo"

    @QtCore.Slot(result=int)
    def val(self):
    v = self.r + 10
    return v

    @QtCore.Slot(result=str)
    def giveit(self):
    return self.s
    @

    and then in the QML :
    @helloText.text = getstuffdone.val()@

    the Value is always shows up 1
    and it is same for returning strings. The returned string is empty.

    and I also checked with the pyside examples and it does same issue (see example qmltopy2), the rotation does not pick up.

    any idea how to make it work?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      adhorn
      wrote on last edited by
      #2

      oo and in my main.py i aslo do :
      @
      if name == "main":
      import sys

      initiate the main QML application

      app = QtGui.QApplication(sys.argv)

      myClass

      view = QtDeclarative.QDeclarativeView()

      getstuffdone = Communicate()

      timer = QtCore.QTimer()
      timer.start(2000)
      context = view.rootContext()

      context.setContextProperty("getstuffdone", getstuffdone)

      view.setSource(QtCore.QUrl('book.qml'))

      view.show()

      execute

      sys.exit(app.exec_())
      @

      1 Reply Last reply
      0
      • R Offline
        R Offline
        renato.filho
        wrote on last edited by
        #3

        hi adhorn, this was fixed on PySide git version. A new version with this and others bugs fixes will be released soon.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jech
          wrote on last edited by
          #4

          I guess the not working pytoqml1 example is the same case, right? If not, I'll provide more details. Basically the problem is, that Python doesn't see QML/JavaScript functions and raises and error if you to try to execute them.

          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