0

I have a GUI I created with QtDesigner that includes some images for buttons. Within QtDesigner they are stored together in a resource file. When I run pyside-uic -x ui_mainWindow.ui -o ui_mainWindow.py or pyside-uic -o ui_mainWindow.py ui_mainWindow.ui, the resulting python code includes lines like:

icon.addPixmap(QtGui.QPixmap(":/assets/CU LASP.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)

but I want it to say

icon.addPixmap(QtGui.QPixmap("./assets/CU LASP.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)

(just use a ./ instead of a :/). When I run the python code with the :/, the images don't show up. When I do a hard code change to ./, the images do show up.

James Paul Mason
  • 1,051
  • 1
  • 13
  • 27
  • The default search path is to search only in the root. Maybe try https://srinikom.github.io/pyside-docs/PySide/QtCore/QDir.html#PySide.QtCore.PySide.QtCore.QDir.addSearchPath – WNG Mar 26 '17 at 17:55
  • I'd like not to have to do any manual editing to the .py file since it gets replaced every time I do an update in QtDesigner and then run pyside-uic. – James Paul Mason Mar 26 '17 at 18:15
  • You also need to compile a resource module with `pyside-rcc`. – ekhumoro Mar 26 '17 at 23:30
  • That's true, and I've tried. That too results in an error saying it can't find the image(s). But I thought that was a separate issue from this. – James Paul Mason Mar 27 '17 at 16:44

0 Answers0