PDA

View Full Version : How to change QMainWindow's tool bar icon for Windows Xp OS



Channareddy
22nd June 2011, 13:26
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,

Rachol
22nd June 2011, 15:34
Do you mean MainWindow icon? In that case: setWindowIcon( const QIcon & icon )

Channareddy
27th June 2011, 13:47
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,

Santosh Reddy
27th June 2011, 13:59
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

Rachol
27th June 2011, 14:03
This worked for me:


#include <QtGui>
#include <QWidget>

int main(int argc, char * argv[])
{
QApplication app (argc, argv);
app.setWindowIcon(QIcon("logo.png"));

QWidget w;
w.show();

return app.exec();
}


Make sure your file path is correct

kunashir
28th June 2011, 12:41
If You use Qt-Creator, you may change icon in visual editor of form in Creator.