Results 1 to 1 of 1

Thread: Trouble displaying an image in PyQt4

  1. #1
    Join Date
    Jun 2018
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Trouble displaying an image in PyQt4

    I am attempting to learn how to use PyQt4. For some reason I can not seem to display this logo.

    Qt Code:
    1. import sys
    2. from PyQt4 import QtGui
    3.  
    4. class Window(QtGui.QMainWindow):
    5. def __init__(self):
    6. super(Window, self).__init__() #returns parent object (q main window object)
    7. self.setGeometry(50, 50, 500, 300)
    8. self.setWindowTitle("PyQt4 Window")
    9.  
    10. y = '/home/rob/PycharmProjects/untitled/Logo.jpg'
    11.  
    12. self.setWindowIcon(QtGui.QIcon(y))
    13. self.show()
    14.  
    15. app = QtGui.QApplication(sys.argv)
    16. GUI = Window()
    17.  
    18. sys.exit(app.exec_())
    To copy to clipboard, switch view to plain text mode 

    What am I doing wrong?

    EDIT: using Ubuntu 16.04 and py3


    Added after 31 minutes:


    Is there a way to mark these posts as solved? Turns out it is working. I was expecting the image to show up on the actual pop-up window; however, it appears on the icon in the task bar not the window and I just never noticed until a moment ago.
    Last edited by Vysero; 29th June 2018 at 21:39.

Similar Threads

  1. Show Dicom Image using PyQt4
    By Pedro Monteiro in forum Qt Programming
    Replies: 3
    Last Post: 15th July 2018, 15:53
  2. Trouble with executable icon image
    By jshafferman in forum Qt Programming
    Replies: 2
    Last Post: 29th September 2011, 16:01
  3. Replies: 0
    Last Post: 7th May 2010, 22:45
  4. [PyQt4] Trouble with event handling
    By Dodle in forum Qt Programming
    Replies: 4
    Last Post: 5th May 2009, 04:45
  5. Trouble with image painting (QPainter + QImage)
    By krivenok in forum Qt Programming
    Replies: 1
    Last Post: 4th February 2006, 20:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.