Type errors using QInputDialog()



  • I am cutting and pasting examples that work into my app and I get these errors.

    bq. Traceback (most recent call last):
    File "/home/me/scripts/ghf/ghf.py", line 295, in bkill
    QtCore.QDir.home().dirName())
    TypeError: 'PySide.QtGui.QInputDialog.getText' called with wrong argument types:
    PySide.QtGui.QInputDialog.getText(Ui_StatCheck, str, str, PySide.QtGui.QLineEdit.EchoMode, unicode)
    Supported signatures:
    PySide.QtGui.QInputDialog.getText(PySide.QtGui.QWidget, unicode, unicode, PySide.QtGui.QLineEdit.EchoMode = QLineEdit.Normal, unicode = QString(), PySide.QtCore.bool, PySide.QtCore.Qt.WindowFlags = 0)
    PySide.QtGui.QInputDialog.getText(PySide.QtGui.QWidget, unicode, unicode, PySide.QtGui.QLineEdit.EchoMode, unicode, PySide.QtCore.bool, PySide.QtCore.Qt.WindowFlags, PySide.QtCore.Qt.InputMethodHints)

    The python code for the GUI is generated by pyside-uic and it defines a class as "class Ui_MainWindow(object):"

    I've noticed in the example I am using the class is defined as "class Dialog(QtGui.QDialog):" so I am assuming that is the root of my problem.

    This is the function definition from the example;
    @def setText(self):
    text, ok = QtGui.QInputDialog.getText(self, "QInputDialog.getText()",
    "User name:", QtGui.QLineEdit.Normal,
    QtCore.QDir.home().dirName())
    if ok and text != '':
    self.textLabel.setText(text)@

    The function is called with "pushButton.clicked.connect(self.setText)". Since my signal is part of an 'object' class instead of a 'QtGui.Qdialog' class how do I invoke an input dialog?



  • I found another method for getting the required input.

    Still curious how to pass the proper types to QInputDialog but at least I'm not DIW on my project.

    Thanks to all.



  • Replaced 'self' with 'MainWindow' and the function worked.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.