Answer the question
In order to leave comments, you need to log in
Why are there problems when using pyQt4 with python3 but not with python2?
Hello. Just started learning pyqt. For this I use the book Rapid GUI Programming with Python and Qt.
There is such a part of the code (entirely taken from the book).
settings = QtCore.QSettings()
self.recentFiles = settings.value('RecentFiles').toStringList()
size = settings.value('MainWindow/Size', QtCore.QVariant(QtCore.QSize(600, 500))).toSize()
self.resize(size)
position = settings.value('MainWindow/Position', QtCore.QVariant(QtCore.QPoint(0, 0)))\
.toPoint()
self.move(position)
self.restoreState(settings.value('MainWindow/State').toByteArray())
self.setWindowTitle('Image Changer')
self.updateFileMenu()
QtCore.QTimer.singleShot(0, self.loadInitialFile)
line 123, in __init__
self.recentFiles = settings.value('RecentFiles').toStringList()
AttributeError: 'NoneType' object has no attribute 'toStringList'
# self.recentFiles = settings.value('RecentFiles').toStringList()
, and we getline 125, in __init__
size = settings.value('MainWindow/Size', QtCore.QVariant(QtCore.QSize(600, 500))).toSize()
TypeError: PyQt4.QtCore.QVariant represents a mapped type and cannot be instantiated
Answer the question
In order to leave comments, you need to log in
PyQT4 has two API versions (v1, v2)
Under python3, PyQT4 provides access to API v2 by default
pyqt.sourceforge.net/Docs/PyQt4/pyqt_qsettings.htm...
As far as I understand, in the book "Rapid GUI Programming with Python and Qt " examples use api v1.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question