Hello,

On 3/14/20 3:59 AM, JZA wrote:
I have been going through different examples, and I am unable to recognize the best way to declare QMainWindow on Python.

I have seen examples like the following:

class MyWindow(QMainWindow):

     def __init__(self, parent=None):
         super(MyWindow, self).__init__(*args, **kwargs)

and others like:

class MyWidget(QtWidgets.QWidget):
     def __init__(self, parent=None):
         QtWidgets.QWidget.__init__(self, parent)

I know the reply would probably be depends, but wonder whats the standard way to declare a Window and a widget like a group form on QFormLayout for example.

This was addressed on one of the webinars:
https://www.youtube.com/watch?v=HDBjmSiOBxY&feature=emb_title&t=7m8s
(Keep in mind the time is 7:08)

Personally,
I prefer to be explicit with it,
so it's:

QWidget.__init__(self, parent)

Since time to time I had issues using super()
when inheriting from multiple classes.

But the three described ways are equivalent,
and there is no "proper way" AFAIK.

Cheers


--
Dr. Cristian Maureira-Fredes
R&D Manager

The Qt Company GmbH
Erich-Thilo-Str. 10
D-12489 Berlin

Geschäftsführer: Mika Pälsi,
Juha Varelius, Mika Harjuaho
Sitz der Gesellschaft: Berlin,
Registergericht: Amtsgericht
Charlottenburg, HRB 144331 B
_______________________________________________
PySide mailing list
PySide@qt-project.org
https://lists.qt-project.org/listinfo/pyside

Reply via email to