Quote:
Originally Posted by kovidgoyal
@davidfor: The PyQt5.Qt module was a shortcut module for importing other Qt classes from a common namespace that was removed in PyQt6. It should not be used and and definitely not aliased as QtGui which is a different module altogether.
Indeed, from calibre 5.13 onwards you can simply do all Qt related imports as
from qt.core import whatever
It works on qt 5 and qt 6. This is what is used in calibre source code itself.
|
The example I was looking at was the Goodreads Metadata source plugin. Which was one of @kiwidudes. The code for importing Qt is:
Code:
try:
from PyQt5 import Qt as QtGui
from PyQt5.Qt import (QTableWidgetItem, QVBoxLayout, Qt, QGroupBox, QTableWidget,
QCheckBox, QAbstractItemView, QHBoxLayout, QIcon,
QInputDialog)
except ImportError:
from PyQt4 import QtGui
from PyQt4.Qt import (QTableWidgetItem, QVBoxLayout, Qt, QGroupBox, QTableWidget,
QCheckBox, QAbstractItemView, QHBoxLayout, QIcon,
QInputDialog)
And then used like:
Code:
spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
button_layout.addItem(spacerItem1)
remove_mapping_button = QtGui.QToolButton(self)
And that's pretty common in the plugins. I assume the first line was a cheat so that we didn't have to change the code that was using QtGui from Qt4. I'll have a look to see how easy it is to change, but, it might be time to drop the Qt4 support.