1

我正在使用 Qwizard 编写一个 pyqt 程序。在一个屏幕上,我正在运行一个线程并通过 Popen 启动一个命令行程序。但是我收到以下警告消息:

QObject::connect: 无法对“QTextCursor”类型的参数进行排队(确保使用 qRegisterMetaType() 注册了“QTextCursor”。)

该程序通常会继续运行,但在此之后会立即崩溃,这让我觉得它是相关的。

由于程序代码太多无法附加,以下是相关片段:

class Fee(QThread):
    def __init__(self, parent=None, options=None):
        QThread.__init__(self, parent)
        #set the given options
        if options:
            self.__options = options

    def copy(self, devicename, outputfilename): 
        self.__device = devicename
        self.__outputfile = outputfilename
        self.start()

    def run(self):
        cmd = self.__getCommandLine(self.options, self.__device, self.__outputfile)
        logging.info("Running Fee with command %s" % (cmd))
        #start the process
        output = ""
        process = Popen(shlex.split(cmd), stdout= PIPE, stderr= STDOUT)
        stderr = process.communicate()[1] 

class FeeManager(QtCore.QObject):
    def copyAndVerify(self):
        self.__fee = Fee(self, self.options)
        self.connect(self.__fee, QtCore.SIGNAL("finished()"), self._setCopyFinished)
        self.connect(self.__fee, QtCore.SIGNAL("progressUpdated(QString, int, QString)"), self._setCopyProgress)

        devicename = self.device.blockdevice
        self.__image_outputfilename = "output_file.img")
        self.__fee.copy(devicename, self.__image_outputfilename) 



class FeeWizardPage(QtGui.QWizardPage):
    def initializePage(self):
        #already earlier in another wizard page is the following: self.feemanager = FeeManager(self, info) 
        self.connect(self.wizard().feemanager, QtCore.SIGNAL("copyProgressUpdated(QString, int, QString)"), self.updateCopyProgress)
        self.connect(self.wizard().feemanager, QtCore.SIGNAL("verifyProgressUpdated(QString, int, QString)"), self.updateVerifyProgress)
        self.connect(self.wizard().feemanager, QtCore.SIGNAL("finished(PyQt_PyObject)"), self.setDone)
        self.wizard().feemanager.copyAndVerify()  

我究竟做错了什么?我怎样才能避免这个消息,并希望给程序带来一些稳定性。我已经搜索了互联网和这个论坛,虽然我已经为其他人尝试了一些建议,但没有一个可以解决这个问题。即使我注释掉所有信号并连接,我仍然会收到相同的警告消息。

有人可以帮忙吗?

非常感谢。

4

0 回答 0