PDA

View Full Version : windowTitle in an MDI application



charlesD
7th November 2006, 20:55
Can someone tell me how to properly handle the situation described below. I apologize for the description length, but it's a very specific situation:

I have an application which allows opening a project file and multiple associated child windows. When the App is running without an open project, the application name is placed into the title bar (in the app constructor) using:
QWidget::setWindowTitle(QApplication::applicationN ame());

When I open a project, I place the project name with the application name in the title bar:
QWidget::setWindowTitle(tr("%1 - %2").arg(QApplication::applicationName())
.arg(this->mpProject->userFriendlyCurrentFile()))

After opening the project, I open one child window to start with, (the user can open additional child windows at a later time if desired). Each child window has its own title set:
ChildWindow::setWindowTitle("View%1").arg(counter++);

Once the initial child window is created, I call showMaximized on the child window, which works fine the first time, i.e. title bar shows: "AppName - ProjectNameA [View1]". If I close my project - which resets the title to the app name only, and then reopen a different project, the title bar is initially set to the correct "Appname - ProjectNameB". However, when I create a child window for the new project and showMaximized is called on the new child window, the first opened project name is redisplayed: "AppName - ProjectNameA [View1]". It seems the original project name is still stored somewhere in memory.

Is there a better way to handle titling windows that will avoid this issue?

I am using Qt version 4.1.4 in Windows XP - Visual Studio .Net 2003

Thanks for any help....

wysota
19th November 2006, 11:49
Could you post a minimal compilable example reproducing the problem? Have you tried upgrading to 4.2.1?

charlesD
21st November 2006, 15:23
Wysota,

Thanks for your response. I actually ended up submitting the problem to TrollTech and they found this was a bug in QWorkspace. I attached the patch I was sent, which I haven't gotten a chance to rebuild the Qt libraries yet to verify it works, but I'm assuming it does.


Hopefully this will help anyone else who runs into the same problem....