0

I'm developing an application with PySide 1.1.2, which is before the new style signals and slots were integrated. I haven't had any issue with most of my custom signals, except those which accept unicode or str types. Those with no parameters, or other types work just fine, but with unicode or str parameters, I get the error: "TypeError: Value types used on meta functions (including signals) need to be registered on meta type: str" on the emit statement.

Example of statements (these are of course in different classes):

self.emit(QtCore.SIGNAL('setCountType(str)'), self.countType)

self.connect(self.parent, QtCore.SIGNAL('setCountType(str)'), self.setCountType)

# part of a class that inherits from QWidget
def setCountType(self, value):
  self.countType = value

The emit statement is the one that throws the error.

virtuesplea
  • 277
  • 6
  • 16

1 Answers1

1

PySide 1.1.2 supports the new style. In my case, signals using "strings" works flawlessly. In case you need some help, check this: http://qt-project.org/wiki/Signals_and_Slots_in_PySide

An example:

import sys
from PySide.QtGui import *
from PySide.QtCore import *

class Window(QMainWindow):
    signal = Signal(str)

    def __init__(self, parent=None):
        super(Window, self).__init__(parent)
        self.button = QPushButton()
        self.button.setText("Test")
        self.setCentralWidget(self.button)
        self.button.clicked.connect(self.button_clicked)
        self.signal.connect(self.print_text)

    @Slot()
    def button_clicked(self):
        print('button clicked')
        self.signal.emit("It works!")

    @Slot(str)
    def print_text(self, text: str):
        print(text)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = Window()
    window.show()
    app.exec_()
    sys.exit(0)
Angel
  • 360
  • 6
  • 13
  • Between this answer and that at http://stackoverflow.com/questions/9712461/pyside-wait-for-signal-from-main-thread-in-a-worker-thread, I was able to piece together how to get slots from my parent window to respond to signals from my custom QWidgets – virtuesplea Aug 14 '13 at 20:36