Hi. I've got a question. How to set window's (dialog's or mainwindow's) icon? Regards
Hi. I've got a question. How to set window's (dialog's or mainwindow's) icon? Regards
Try QWidget::setWindowIcon().
Like that?
Qt Code:
#include <QApplication> #include <QPlastiqueStyle> #include "maker.h" #include "about.h" int main(int argc, char *argv[]) { MainWindow MainWindow; MainWindow.show(); return app.exec(); }To copy to clipboard, switch view to plain text mode
Don't forget the quotes around the file path. And beware of using relative paths.
I have new.png in my resuorce file. But there's an error:
main.cpp:10:error: cannot call member function 'void QWidget::SetWindowIcon (const QIcon&) without object. I don't know what's this problem about, I have new.png in my resource file included in project. Regards
setWindowIcon is not a static method. Call it as a regular method of your widget. Please read and try to understand the messages compiler gives you. It doesn't say anything about the icon, does it?
Yes, It doesn't. Of cource I read this message, but I don't understand what's this "without object" about
So, what's the problem about? Regards
Yes, It doesn't. Of cource I read this message, but I don't understand what's this "without object" about
you are calling QWidget::setWindowIcon(QIcon (new.png));
while you should be calling -
someObject.setWindowIcon(QIcon (new.png));
or mainWindow.setWindowIcon(QIcon (new.png));
is that clear now ?? without object thing ??
Yes, it's clear, thanks
Bookmarks