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. Getting compliation error in using connect in pyqt4
Forum Updated to NodeBB v4.3 + New Features

Getting compliation error in using connect in pyqt4

Scheduled Pinned Locked Moved Unsolved Qt for Python
5 Posts 3 Posters 469 Views 1 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #1

    I have 2 objects in a class

    QtCore.QObject.connect(self.voTreeView,QtCore.SIGNAL("copySignal(list)"),self.metricsTreeView,QtCore.SLOT(self.metricsTreeView.clipboardData))

    I have my own customised signal and I want to send the list from one object to other object

    I am getting following error

    QtCore.QObject.connect(self.voTreeView,QtCore.SIGNAL("copySignal(list)"),self.metricsTreeView,QtCore.SLOT(self.metricsTreeView.clipboardData))
    TypeError: SLOT(str): argument 1 has unexpected type 'instancemethod'

    Could you please let me know how correct the compilation issue

    JonBJ 1 Reply Last reply
    0
    • Q Qt Enthusiast

      I have 2 objects in a class

      QtCore.QObject.connect(self.voTreeView,QtCore.SIGNAL("copySignal(list)"),self.metricsTreeView,QtCore.SLOT(self.metricsTreeView.clipboardData))

      I have my own customised signal and I want to send the list from one object to other object

      I am getting following error

      QtCore.QObject.connect(self.voTreeView,QtCore.SIGNAL("copySignal(list)"),self.metricsTreeView,QtCore.SLOT(self.metricsTreeView.clipboardData))
      TypeError: SLOT(str): argument 1 has unexpected type 'instancemethod'

      Could you please let me know how correct the compilation issue

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Qt-Enthusiast said in Getting compliation error in using connect in pyqt4:

      QtCore.QObject.connect(self.voTreeView,QtCore.SIGNAL("copySignal(list)"),self.metricsTreeView,QtCore.SLOT(self.metricsTreeView.clipboardData))
      TypeError: SLOT(str): argument 1 has unexpected type 'instancemethod'
      

      Your QtCore.SIGNAL("...")correctly takes a string parameter. In your QtCore.SLOT(self.metricsTreeView.clipboardData) you are passing a method/callable instead of a string. Doesn't QtCore.SLOT() require a string like QtCore.SIGNAL() does? I suspect you intend:

      QtCore.QObject.connect(self.voTreeView, QtCore.SIGNAL("copySignal(list)"), self.metricsTreeView, self.metricsTreeView.clipboardData)
      

      You probably already know that you would benefit from moving to PyQt5. But even later versions of PyQt4 introduced support for new-style signal/slots, which would have helped here. Is this legacy code which is no longer actively developed?

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        Qt Enthusiast
        wrote on last edited by Qt Enthusiast
        #3

        https://paste.ofcode.org/eG2QgwngRbwJdq933jdKS3

        Not working . Can u some one tell the solution

        1.png t](image url)

        JonBJ 2 Replies Last reply
        0
        • Q Qt Enthusiast

          https://paste.ofcode.org/eG2QgwngRbwJdq933jdKS3

          Not working . Can u some one tell the solution

          1.png t](image url)

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Qt-Enthusiast
          Since your latest code paste uses new-style signal/slot syntax for connect(), why did you bother asking about your old-style QtCore.QObject.connect(...) code?

          1 Reply Last reply
          0
          • Q Qt Enthusiast

            https://paste.ofcode.org/eG2QgwngRbwJdq933jdKS3

            Not working . Can u some one tell the solution

            1.png t](image url)

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @Qt-Enthusiast
            In your pasted code:

            t1.mysignal = QtCore.pyqtSignal(list)
            

            How is this setting a class variable? It is setting an instance variable, while you need it to be a class variable in class Test.

            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