title: Promoting widgets and using them from generated ui
body: <p>I am trying to create a custom widget by promoting it in Qt Designer. The problem is, Qt Designer automatically prepends <code>Ui_</code> to widget names. This leads to error in code generated for MainWindow:</p>
  
  <pre><code>ImportError: cannot import name 'promotedWidget'
  </code></pre>
  
  <p>I can fix this error by renaming the widget (prepending <code>Ui_</code>) in Qt Designer, while promoting. But then, I get this error:</p>
  
  <pre><code>TypeError: object() takes no parameters
  </code></pre>
  
  <p>I got around this error by creating a new Python file that just wraps around <code>promotedWidget</code>:</p>
  
  <pre><code>from PyQt5 import QtCore, QtGui, QtWidgets
  from promotedwidget_raw import Ui_promotedWidget
  
  class Ui_promotedWidget(Ui_promotedWidget, QtWidgets.QWidget):
      def setupUi(self, promotedWidget):
          super().setupUi(promotedWidget)
  
  if __name__ == "__main__":
      import sys
      app = QtWidgets.QApplication(sys.argv)
      promotedWidget = QtWidgets.QWidget()
      ui = Ui_promotedWidget()
      ui.setupUi(promotedWidget)
      promotedWidget.show()
      sys.exit(app.exec_())
  </code></pre>
  
  <p>This fixes the problem, but I don't like the idea of creating a wrapper just to get custom widget to work. (And I am pretty sure I'm doing it wrong)</p>
  
  <p>Here are my (example) project files:</p>
  
  <pre><code>main.py
  main_gui.pyw # Generated from ui
  main_gui.ui
  promotedwidget.pyw # Generated from ui
  promotedwidget.ui
  </code></pre>
  
  <hr>
  
  <p>main.py:</p>
  
  <pre><code>import sys
  
  from PyQt5 import QtWidgets
  from main_gui import Ui_MainWindow as MainWindow
  
  app = QtWidgets.QApplication(sys.argv)
  
  MainWindow = QtWidgets.QMainWindow()
  
  ui = Ui_MainWindow()
  ui.setupUi(MainWindow)
  
  MainWindow.show()
  
  sys.exit(app.exec_())
  </code></pre>
  
  <hr>
  
  <p>main_gui.pyw:</p>
  
  <pre><code># -*- coding: utf-8 -*-
  
  # Form implementation generated from reading ui file 'main_gui.ui'
  #
  # Created by: PyQt5 UI code generator 5.8.2
  #
  # WARNING! All changes made in this file will be lost!
  
  from PyQt5 import QtCore, QtGui, QtWidgets
  
  class Ui_MainWindow(object):
      def setupUi(self, MainWindow):
          MainWindow.setObjectName("MainWindow")
          MainWindow.resize(800, 600)
          self.centralwidget = QtWidgets.QWidget(MainWindow)
          self.centralwidget.setObjectName("centralwidget")
          self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
          self.gridLayout.setObjectName("gridLayout")
          self.widget = promotedWidget(self.centralwidget)
          self.widget.setObjectName("widget")
          self.gridLayout.addWidget(self.widget, 0, 0, 1, 1)
          MainWindow.setCentralWidget(self.centralwidget)
          self.menubar = QtWidgets.QMenuBar(MainWindow)
          self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
          self.menubar.setObjectName("menubar")
          MainWindow.setMenuBar(self.menubar)
          self.statusbar = QtWidgets.QStatusBar(MainWindow)
          self.statusbar.setObjectName("statusbar")
          MainWindow.setStatusBar(self.statusbar)
  
          self.retranslateUi(MainWindow)
          QtCore.QMetaObject.connectSlotsByName(MainWindow)
  
      def retranslateUi(self, MainWindow):
          _translate = QtCore.QCoreApplication.translate
          MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
  
  from promotedwidget import promotedWidget
  
  if __name__ == "__main__":
      import sys
      app = QtWidgets.QApplication(sys.argv)
      MainWindow = QtWidgets.QMainWindow()
      ui = Ui_MainWindow()
      ui.setupUi(MainWindow)
      MainWindow.show()
      sys.exit(app.exec_())
  </code></pre>
  
  <hr>
  
  <p>promotedwidget.pyw:</p>
  
  <pre><code># -*- coding: utf-8 -*-
  
  # Form implementation generated from reading ui file 'promotedwidget.ui'
  #
  # Created by: PyQt5 UI code generator 5.8.2
  #
  # WARNING! All changes made in this file will be lost!
  
  from PyQt5 import QtCore, QtGui, QtWidgets
  
  class Ui_promotedWidget(object):
      def setupUi(self, promotedWidget):
          promotedWidget.setObjectName("promotedWidget")
          promotedWidget.resize(400, 300)
          self.gridLayout = QtWidgets.QGridLayout(promotedWidget)
          self.gridLayout.setObjectName("gridLayout")
          self.label = QtWidgets.QLabel(promotedWidget)
          self.label.setObjectName("label")
          self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
  
          self.retranslateUi(promotedWidget)
          QtCore.QMetaObject.connectSlotsByName(promotedWidget)
  
      def retranslateUi(self, promotedWidget):
          _translate = QtCore.QCoreApplication.translate
          promotedWidget.setWindowTitle(_translate("promotedWidget", "Form"))
          self.label.setText(_translate("promotedWidget", "Test"))
  
  
  if __name__ == "__main__":
      import sys
      app = QtWidgets.QApplication(sys.argv)
      promotedWidget = QtWidgets.QWidget()
      ui = Ui_promotedWidget()
      ui.setupUi(promotedWidget)
      promotedWidget.show()
      sys.exit(app.exec_())
  </code></pre>
  
  <p>I have searched for how to make custom widgets with PyQt and Qt Designer, but I couldn't find an answer that matches my needs. Or I just couldn't wrap my head around the process yet.</p>