View Single Post
Old 01-04-2022, 12:31 AM   #39
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by kovidgoyal View Post
@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.
davidfor is offline   Reply With Quote