Hi Alexander, (forwarding to qgis-dev list, as I think it should be also referenced there)
Here is the reply I got from Phil: > I can confirm it is a bug, however the fix is non-trivial so it won't get fixed quickly. The fundamental problem is that the code has the assumption that all custom widgets will reside in the PyQt5 package hard-coded (but even then it's not quite as simple as that). He also wrote it's on his todo list in the next 3-4 weeks on that time, but I don't think it has been solved. Best wishes, Denis Le jeu. 30 août 2018 à 08:35, Alexander Bruy <[email protected]> a écrit : > Hi all, > > usually I use following code to create a form from the Qt Designer's .ui > file dynamically > > from PyQt5 import uic > FORM_CLASS, BASE_CLASS = uic.loadUiType('/path/to/ui/file.ui') > > class MyDialog(BASE_CLASS, FORM_CLASS): > def __init__(self, parent=None): > super(MyDialog, self).__init__(parent) > self.setupUi(self) > > and everything works fine. > > But seems this approach seems does not work with multiple inheritance. > There is a custom dialog class (QDialog subclass with custom UI and some > logic) available in the API library. I want to subclass this custom dialog > and also apply my own UI to it. I tried following code > > from PyQt5 import uic > from api.ui import CustomDialogBase > > FORM_CLASS, BASE_CLASS = uic.loadUiType('/path/to/ui/file.ui') > > class MyDialog(BASE_CLASS, CustomDialogBase, FORM_CLASS): > def __init__(self, parent=None): > super(MyDialog, self).__init__(parent) > self.setupUi(self) > > But this raises type error > > TypeError: Cannot create a consistent method resolution order (MRO) > for bases QDialog, QgsOptionsDialogBase, Ui_OptionsDialog > > As I understand, this is because all classes have the same base class > QDialog. > > Also I tried to specify only one parent class — custom dialog, as it is > already subclassed from QDialog > > from PyQt5 import uic > from api.ui import CustomDialogBase > > FORM_CLASS, BASE_CLASS = uic.loadUiType('/path/to/ui/file.ui') > > class MyDialog(CustomDialogBase, FORM_CLASS): > def __init__(self, parent=None): > super(MyDialog, self).__init__(parent) > self.setupUi(self) > > But this also does not work, with the error > > AttributeError: 'MyDialog' object has no attribute 'groupBox' > > As I understand, in this case issue is that FORM_CLASS is a QDialog > subclass, > not CustomDialogBase's subclass. After some searching I have found this > thread > https://riverbankcomputing.com/pipermail/pyqt/2017-October/039647.html. > Am I right that currently the only way to solve my issue is to construct > form from the compiled .ui file? > > Thanks > > -- > Alexander Bruy > _______________________________________________ > PyQt mailing list [email protected] > https://www.riverbankcomputing.com/mailman/listinfo/pyqt -- Denis Rouzaud [email protected] <[email protected]> +41 76 370 21 22
_______________________________________________ QGIS-Developer mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
