PDA

View Full Version : icon next to window title



duma
15th August 2011, 19:37
I have an .jpg image that I want to place next to my QMainWindow title. how do I do this? Any help would be appreciated.

ChrisW67
15th August 2011, 23:07
Do you mean setting the application icon that typically occupies the leftmost end of the window title bar, putting another image elsewhere in the window title bar, or something else? What operating system(s)?

Andre_Mikulec
16th August 2011, 04:35
PySide 1.0.5 (Qt 4.7) supported formats.

READER

# QImageReader.supportedImageFormats()
# [ PySide.QtCore.QByteArray('bmp'),
# PySide.QtCore.QByteArray('gif'),
# PySide.QtCore.QByteArray('ico'),
# PySide.QtCore.QByteArray('jpeg'),
# PySide.QtCore.QByteArray('jpg'),
# PySide.QtCore.QByteArray('mng'),
# PySide.QtCore.QByteArray('pbm'),
# PySide.QtCore.QByteArray('pgm'),
# PySide.QtCore.QByteArray('png'),
# PySide.QtCore.QByteArray('ppm'),
# PySide.QtCore.QByteArray('tif'),
# PySide.QtCore.QByteArray('tiff'),
# PySide.QtCore.QByteArray('xbm'),
# PySide.QtCore.QByteArray('xpm')
# ]

This PySide code works for me.


import sys
from PySide.QtCore import *
from PySide.QtGui import *
from PySide.QtWebKit import *

app = QApplication(sys.argv)

# WORKS fiie must be in the same dir as the main.py file
# absolute does not work
# 'F:\Documents and Settings\Administrator\My Documents\andre16x16at24bit.bmp'
# relative addressing does not work
# '..\andre16x16at24bit.bmp'
q_pixmap = QPixmap('andre16x16at24bit.bmp')
q_icon = QIcon(q_pixmap)
QApplication.setWindowIcon(q_icon)

web = QWebView()
web.load(QUrl("http://www.google.com"))
web.show()

sys.exit(app.exec_())

duma
16th August 2011, 15:08
Do you mean setting the application icon that typically occupies the leftmost end of the window title bar, putting another image elsewhere in the window title bar, or something else? What operating system(s)?

I am operating on 64-bit linux. Your first guess was right. I mean setting the application icon that typically occupies the leftmost end of the window title bar.
Sorry for the lack of info.

NullPointer
16th August 2011, 23:10
Have you tried the setWindowIcon setter from QWidget?
That is:


web.setWindowIcon(q_icon);


Hth.

duma
18th August 2011, 16:57
Thanks guys, this worked:

wave w; //wave is my class
w.setWindowIcon(QIcon("/image.jpg"));