Results 1 to 6 of 6

Thread: How to change QMainWindow's tool bar icon for Windows Xp OS

  1. #1
    Join Date
    Jun 2011
    Posts
    26
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default How to change QMainWindow's tool bar icon for Windows Xp OS

    Hi,
    I want to change the icon of QMainWindow tool bar which is displayed at the left most corner of the window.How do i do it.Is there any in build methods for that in Qt or we need to write our own .Please explain me along with code ASAP.

    Thank you,

  2. #2
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: How to change QMainWindow's tool bar icon for Windows Xp OS

    Do you mean MainWindow icon? In that case: setWindowIcon( const QIcon & icon )

  3. #3
    Join Date
    Jun 2011
    Posts
    26
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: How to change QMainWindow's tool bar icon for Windows Xp OS

    I tried with setWindowIcon(const QIcon & icon) but did not getting.Please explain briefly as to what should i do.I am working on Windows Xp OS with Qt 4.7.3.


    Thanks,

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: How to change QMainWindow's tool bar icon for Windows Xp OS

    Call setWindowIcon(QIcon("C:/filepath/xxxxx.png")); from the MainWindows's ctor, if this does not work make sure you have the icon file is in that path, and is of supported file type

  5. #5
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: How to change QMainWindow's tool bar icon for Windows Xp OS

    This worked for me:
    Qt Code:
    1. #include <QtGui>
    2. #include <QWidget>
    3.  
    4. int main(int argc, char * argv[])
    5. {
    6. QApplication app (argc, argv);
    7. app.setWindowIcon(QIcon("logo.png"));
    8.  
    9. w.show();
    10.  
    11. return app.exec();
    12. }
    To copy to clipboard, switch view to plain text mode 

    Make sure your file path is correct

  6. #6
    Join Date
    Mar 2011
    Location
    Russia, Lipetsk
    Posts
    17
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to change QMainWindow's tool bar icon for Windows Xp OS

    If You use Qt-Creator, you may change icon in visual editor of form in Creator.

Similar Threads

  1. How to change QMainWindow size at runtime?
    By myfifth in forum Newbie
    Replies: 11
    Last Post: 10th January 2011, 06:18
  2. Hide QMainWindow without removing taskbar icon?
    By bigchiller in forum Qt Programming
    Replies: 5
    Last Post: 15th March 2009, 22:54
  3. Custom QStyle: change only tool button text color
    By Lykurg in forum Qt Programming
    Replies: 0
    Last Post: 27th February 2009, 19:55
  4. How to keep tool windows activated
    By marcel in forum Qt Programming
    Replies: 1
    Last Post: 13th May 2007, 19:02
  5. tool bar icon size looking small???
    By darpan in forum Qt Tools
    Replies: 7
    Last Post: 31st March 2006, 16:38

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.