[PyQt] upgrade pyqt 4.4.4 to 4.5.4 problems

Phil Thompson phil at riverbankcomputing.com
Tue Aug 11 18:57:18 BST 2009


On Mon, 10 Aug 2009 14:14:16 +0200, Linos <info at linos.es> wrote:
> Hello,
> 	i have upgraded my linux development machine from pyqt 4.4.4 to 4.5.4
(and
> 	sip
> 4.7.9 to 4.8.2) and i am getting any errors with my application. My Qt
> version 
> it is 4.5.2 but errors are related to pyqt version because if i downgrade
> pyqt 
> all works, well obviously can be problems with my code (i think so), but
i
> mean 
> that with pyqt 4.4.4 the code works.
> 
> 1) i am using a QThread to populate large sql queries data to a model in 
> background. Inside the class run method i create a worker object (worker
it
> is a 
> QObject subclass) and run an event loop to connect the worker and the
> thread 
> with signals and slots, it have been running fine with all pyqt 4.4
> versions but 
> i now get this error:
> 
> QObject: Cannot create children for a parent that is in a different
thread.
> (Parent is QueryModelThread(0xa00db20), parent's thread is
> QThread(0x9f0a748), 
> current thread is QueryModelThread(0xa00db20)
> 
> code:
> class QueryModelThread(QThread):
>      def __init__(self, parent=None):
>          super(QueryModelThread, self).__init__(parent)
>          self.worker = None
> 
>      def executeModel(self, texto_query):
>          self.emit(SIGNAL("executeModel"), texto_query)
> 
>      def executeQuery(self, texto_query):
>          self.emit(SIGNAL("executeQuery"), texto_query)
> 
>      def stopIfRunning(self):
>          if self.worker:
>              self.worker.stopIfRunning()
> 
>      def run(self):
>          worker = Worker()
> 
>          self.connect(self, SIGNAL("executeModel"),
>          worker.slotExecuteModel)
>          self.connect(worker, SIGNAL("finalizado"), self,
>          SIGNAL("finalizado"))
>          self.connect(worker, SIGNAL("redimensiona"), self,
>          SIGNAL("redimensiona"))
>          self.connect(worker, SIGNAL("comenzado"), self,
>          SIGNAL("comenzado"))
>          self.connect(worker, SIGNAL("nuevas_filas"), self,
>          SIGNAL("nuevas_filas"))
> 
>          self.connect(self, SIGNAL("executeQuery"),
>          worker.slotExecuteQuery)
>          self.connect(worker, SIGNAL("query_preparada"), self, 
> SIGNAL("query_preparada"))
> 
>          self.worker = worker
>          self.exec_()
> 
> init of the worker class:
> 
> class Worker(QObject):
>      def __init__(self, parent=None):
>          super(Worker, self).__init__(parent)
>          self.db = database.conectarDbTienda("QueryModelThread")
>          self.query = QSqlQuery(self.db)
>          self.stop = self.corriendo = False

Can you produce a test case for this so I can reproduce the problem?

> 2) i have many models that use a set of shared methods (apart from Qt's
> models 
> methods) so i created a python class 
> (editor_documentos_base.EditorDocumentosBaseModel) with all this methods
> and in 
> my models i use this multiple inheritance.
> 
> class AlbaranEntradaModel(QAbstractTableModel, 
> editor_documentos_base.EditorDocumentosBaseModel):
>      def __init__(self, parent):
>          super(AlbaranProveedorModel, self).__init__()
>          editor_documentos_base.EditorDocumentosBaseModel.__init__(self)
> 
> rowCount and columnCount are implemented in this base class and now when
i
> call 
> tableView.setModel(sampleModel) (where sampleModel it is the instance of
> one of 
> my models) i get this errors:
> NotImplementedError: QAbstractTableModel.rowCount() is abstract and must
be
> 
> overridden
> NotImplementedError: QAbstractTableModel.columnCount() is abstract and
must
> be 
> overridden

This is fixed in tonight's SIP snapshot.

> 3) i know that signals and slots have changed with this versions but i
> thought 
> the old syntax it is still support for compatibility, i get this error
> emitting 
> this signal, do i am wrong or this is other problem?
> 
> self.emit(SIGNAL("cambiaFoto(QVariant, QVariant)"), QVariant(),
QVariant())
> TypeError: argument 0 of signal PyQtProxy.ambiaFoto(QVariant,QVariant)
has
> an 
> invalid type

Again, can you produce a test case?

Thanks,
Phil


More information about the PyQt mailing list