Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Image not displaying
Forum Updated to NodeBB v4.3 + New Features

Image not displaying

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 3 Posters 341 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TheShulker
    wrote on last edited by
    #1

    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 run

    pyside6-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
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • CristianMaureiraC Offline
        CristianMaureiraC Offline
        CristianMaureira
        wrote on last edited by
        #3

        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.
        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved