Results 1 to 6 of 6

Thread: icon next to window title

  1. #1
    Join Date
    Aug 2011
    Posts
    35
    Thanks
    5

    Default icon next to window title

    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.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: icon next to window title

    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)?

  3. #3
    Join Date
    Jun 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: icon next to window title

    PySide 1.0.5 (Qt 4.7) supported formats.

    READER
    Qt Code:
    1. # QImageReader.supportedImageFormats()
    2. # [ PySide.QtCore.QByteArray('bmp'),
    3. # PySide.QtCore.QByteArray('gif'),
    4. # PySide.QtCore.QByteArray('ico'),
    5. # PySide.QtCore.QByteArray('jpeg'),
    6. # PySide.QtCore.QByteArray('jpg'),
    7. # PySide.QtCore.QByteArray('mng'),
    8. # PySide.QtCore.QByteArray('pbm'),
    9. # PySide.QtCore.QByteArray('pgm'),
    10. # PySide.QtCore.QByteArray('png'),
    11. # PySide.QtCore.QByteArray('ppm'),
    12. # PySide.QtCore.QByteArray('tif'),
    13. # PySide.QtCore.QByteArray('tiff'),
    14. # PySide.QtCore.QByteArray('xbm'),
    15. # PySide.QtCore.QByteArray('xpm')
    16. # ]
    To copy to clipboard, switch view to plain text mode 

    This PySide code works for me.

    Qt Code:
    1. import sys
    2. from PySide.QtCore import *
    3. from PySide.QtGui import *
    4. from PySide.QtWebKit import *
    5.  
    6. app = QApplication(sys.argv)
    7.  
    8. # WORKS fiie must be in the same dir as the main.py file
    9. # absolute does not work
    10. # 'F:\Documents and Settings\Administrator\My Documents\andre16x16at24bit.bmp'
    11. # relative addressing does not work
    12. # '..\andre16x16at24bit.bmp'
    13. q_pixmap = QPixmap('andre16x16at24bit.bmp')
    14. q_icon = QIcon(q_pixmap)
    15. QApplication.setWindowIcon(q_icon)
    16.  
    17. web = QWebView()
    18. web.load(QUrl("http://www.google.com"))
    19. web.show()
    20.  
    21. sys.exit(app.exec_())
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Aug 2011
    Posts
    35
    Thanks
    5

    Default Re: icon next to window title

    Quote Originally Posted by ChrisW67 View Post
    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.

  5. #5
    Join Date
    Jul 2011
    Location
    Brasil
    Posts
    39
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1
    Thanked 7 Times in 7 Posts

    Default Re: icon next to window title

    Have you tried the setWindowIcon setter from QWidget?
    That is:
    Qt Code:
    1. web.setWindowIcon(q_icon);
    To copy to clipboard, switch view to plain text mode 

    Hth.

  6. The following user says thank you to NullPointer for this useful post:

    duma (18th August 2011)

  7. #6
    Join Date
    Aug 2011
    Posts
    35
    Thanks
    5

    Default Re: icon next to window title

    Thanks guys, this worked:
    Qt Code:
    1. wave w; //wave is my class
    2. w.setWindowIcon(QIcon("/image.jpg"));
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Animated icon on QTabWidget title
    By ramazangirgin in forum Qt Programming
    Replies: 4
    Last Post: 15th July 2010, 13:44
  2. Replies: 0
    Last Post: 6th September 2009, 22:58
  3. Couple of questions: main window icon + toolbar icon
    By bpackard in forum Qt Programming
    Replies: 0
    Last Post: 20th March 2008, 20:03
  4. Replies: 1
    Last Post: 17th January 2008, 11:17
  5. window title bar
    By moowy in forum Qt Programming
    Replies: 4
    Last Post: 21st September 2006, 17:56

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
  •  
Qt is a trademark of The Qt Company.