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

Miguel Cardenas mfcardenas at gmail.com
Sun Dec 14 19:49:45 CET 2008


Hi

It was made by hand and found the problem, it was layer related, once it got
fixed everything worked as expected, sorry am trying Qt 4 for first time,
now and after various tests there's no more problem :)

Thanks

On Thu, Dec 11, 2008 at 11:53 AM, Jesús Fernández <jsfdez at gmail.com> wrote:

> Why are you not calling the QMainWindow constructor?
>
> And the MainWindow has been done with designer?
>
> On Thu, Dec 11, 2008 at 6:38 PM, Miguel Cardenas <mfcardenas at gmail.com>wrote:
>
>> 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
>>
>>
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>>
>


-- 
Miguel Cardenas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20081214/25499f6e/attachment.html 


More information about the Qt-interest-old mailing list