[Qt-interest] Question about setWindowFilePath

Reece Dunn msclrhd at googlemail.com
Thu Apr 15 09:15:46 CEST 2010


Hi,

I am writing an application that has code like the following:

  class MyApp : public QMainWindow
  {
     MyApp()
     {
        QSettings settings;
        loadFile(settings.value("last-open-file").toString());
     }

     void loadFile(const QString &file)
     {
        ...
        setWindowFilePath(file);
     }
  };

I have loadFile hooked up to an Open action event handler and have the
QApplication::applicationName set properly.

This is all working fine, except when loading the last opened file. In
this case, it is showing the executable name in the window title (i.e.
the default), not the "file - application name".

It appears that calling setWindowFilePath does not work properly when
called from the constructor. So:
  1.  Is this a known issue?
  2.  Am I doing something wrong?
  3.  Should I raise a defect for this (if so, where)?
  4.  Is there a way to solve this now (e.g. handle reading settings
on an initialised/created/loaded signal event)?

BTW: This is running on Ubuntu 10.04 with Qt 4.6.2.

This can also be seen with the Main Window > Application demo program
(it displays 'application' instead of 'untitled.txt - Application').

Thanks,
- Reece



More information about the Qt-interest-old mailing list