Image not displaying
-
code:
import sys from PyQt6.QtWidgets import QApplication, QWidget, QLabel, QVBoxLayout from PyQt6.QtGui import QPixmap class MainWindow(QWidget): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setWindowTitle('PyQt Label Widget') self.setGeometry(100, 100, 320, 210) label = QLabel() pixmap = QPixmap('data/download.png') label.setPixmap(pixmap) # place the widget on the window layout = QVBoxLayout() layout.addWidget(label) self.setLayout(layout) # show the window self.show() if __name__ == '__main__': app = QApplication(sys.argv) # create the main window window = MainWindow() # start the event loop sys.exit(app.exec())
Note - the image is only working if I use full path
I tried to runpyside6-rcc resources.qrc -o resources_rc.py
but it gives me
pyside6-rcc : The term 'pyside6-rcc' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + pyside6-rcc resources.qrc -o resources_rc.py + ~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (pyside6-rcc:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
-
Hi and welcome to devnet,
Something is not clear here, you are importing PyQt6 but calling PySide6 tools on the command line.
So which one are you currently installed ?
How did you install it ?
On which OS ? -
And for reference, here you have a tutorial for using icons/images https://doc.qt.io/qtforpython-6/tutorials/basictutorial/qrcfiles.html as @SGaist mentioned, you are mixing two different bindings:
- PyQt6 is developed by Riverbank Computing
- PySide6 is developed by The Qt Company
Even though most of the API is similar, they cannot be mixed.