[Qt-interest] QMainWindow: setWindowTitle() & setWindowIcon() don't work

Miguel Cardenas mfcardenas at gmail.com
Thu Dec 11 18:38:48 CET 2008


Hi list

I made a small application with the new Qt4 to see the changes respect
Qt3... it is finished and working so decided to play with the title bar and
found that setWindowTitle() & setWindowIcon() don't work with QMainWindow...

My first code was like this:

#include "my_pixmap.xpm"

MainWindow::MainWindow (QApplication* app) {
   setWindowTitle(tr("some title"));
   setWindowIcon(QIcon(QPixmap(my_pixmap)));
   ...
}

then replaced by this one:

MainWindow::MainWindow (QApplication* app) {
   setWindowTitle(tr("some title"));
   QApplication::setWindowIcon(QIcon(QPixmap(my_pixmap)));
   ...
}

but it sets the same icon for all my windows, by now it is okay but what if
I want it only for my current QMainWindow?

Respect the setWindowTitle() it didn't work in any tested way, it is always
the name of the executable file..

Tried these combinadions and any worked:

setWindowTitle(tr("some title"));
setWindowTitle(QString("some title"));
setWindowTitle(QString(tr("some title")));

QString title("some title");
setWindowTitle(title);

QString title(tr("some title"));
setWindowTitle(title);

and nothing, the title remains as the executable filename. The documentation
says QMainWindow inherits QWidget that has available both setWindowTitle()
and setWindowIcon() so it should work, but no, the icon only could be
modified via the QApplication::setWindowIcon() and the title in any way.

What is wrong in this code?


Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20081211/76ab6017/attachment.html 


More information about the Qt-interest-old mailing list