How to change the import path of qrc module in Qt Designer
Moved
Unsolved
Qt for Python
-
Im looking for a way to change the import path of the qrc module in the pyuic generated python file.
An example pyuic generated python code from a ui file:
from PyQt5 import QtCore, QtGui, QtWidgets class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(249, 103) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.horizontalLayout = QtWidgets.QHBoxLayout(self.centralwidget) self.horizontalLayout.setObjectName("horizontalLayout") self.pushButton = QtWidgets.QPushButton(self.centralwidget) self.pushButton.setText("") icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(":/gui_icons/res/play.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.pushButton.setIcon(icon) self.pushButton.setIconSize(QtCore.QSize(32, 32)) self.pushButton.setObjectName("pushButton") self.horizontalLayout.addWidget(self.pushButton) MainWindow.setCentralWidget(self.centralwidget) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) import icons_mw_rc
I want to change
icons_mw_rc
import path to another location to better organize my source files [Example:import qrc_res.icons_mw_rc
]. Is there a way to do that using the qt designer without manually modifying the pyuic generated src file. -
pyuic
has a couple of options, among them there is one called--from-imports
that might solve your issue.
https://www.riverbankcomputing.com/static/Docs/PyQt5/designer.html#pyuic5 -
-