Hi
I have a problem with the name of the file when saving it. when I open a new file , its name is untitled.txt and when I modify it the * appears but if I save the file normally there should be only the file name ( without * ) which is not the case and I don't understand where is the problem
here is the function and at the end the title of my window.
thanks
void MainWindow
::setCurrentFile(const QString &fileName
) {
curFile = fileName;
setWindowFilePath(curFile);
QStringList files
= settings.
value("recentFileList").
toStringList();
files.removeAll(fileName);
files.prepend(fileName);
while (files.size() > MaxRecentFiles)
files.removeLast();
settings.setValue("recentFileList", files);
MainWindow *mainWin = qobject_cast<MainWindow *>(widget);
if (mainWin)
mainWin->updateRecentFileActions();
}
if (curFile.isEmpty())
shownName = "untitled.txt";
else
shownName = strippedName(curFile);
setWindowTitle(tr("%1[*] - %2").arg(shownName).arg(tr("my application name")));
}
void MainWindow::setCurrentFile(const QString &fileName)
{
curFile = fileName;
setWindowFilePath(curFile);
QSettings settings;
QStringList files = settings.value("recentFileList").toStringList();
files.removeAll(fileName);
files.prepend(fileName);
while (files.size() > MaxRecentFiles)
files.removeLast();
settings.setValue("recentFileList", files);
foreach (QWidget *widget, QApplication::topLevelWidgets()) {
MainWindow *mainWin = qobject_cast<MainWindow *>(widget);
if (mainWin)
mainWin->updateRecentFileActions();
}
QString shownName;
if (curFile.isEmpty())
shownName = "untitled.txt";
else
shownName = strippedName(curFile);
setWindowTitle(tr("%1[*] - %2").arg(shownName).arg(tr("my application name")));
}
To copy to clipboard, switch view to plain text mode
Bookmarks