Search code examples
pythonpython-3.xpyqt5qt-designer

How to design sub frames separately and add them up in main application


I'm trying to design and create my python application with Qt Designer (using PyQt5).

My Application happens to have lots of buttons and "sub windows" (frames basically) which is quite frustrating to design all at once.

I am wondering if there's a way to design a Frame or a Widget separately and then kind of "Import" it to the main application window?

I couldn't find any and would love to hear if someone knows a way.


Solution

  • You can use promoted widgets for that: design frame and save it to ui file myframe.ui, generate ui class file MyFrame.py using pyuic5 (pyuic5 -o MyFrame.py myframe.ui), add Widget to mainwindow.ui and promote it to MyFrame (promoted class name MyFrame, header file MyFrame.py)