When I am using below code on Linux SLES 11 machine the .ini file is recreating for some reason so that I am not able to restore my settings.
Same code working fine on Windows machine.
Prb: I want to have recently opened file list on start up window, so that user can select quickly.
Window::Window()
{
restoreRecentFileList();
}
Window::~Window()
{
saveRecentFileList();
}
void Window::saveRecentFileList()
{
settings.
setValue("recentFiles/list",
QVariant(m_recentFilesList
));
}
void Window::restoreRecentFileList()
{
m_recentFilesList = settings.value("recentFiles/list").toStringList();
}
void Window
::openFile(QString l_file
) {
if(isValidFile(l_file))
{
m_recentFilesList << l_file;
qDebug() << "connected to : " << l_file;
}
else
{
}
}
Window::Window()
{
restoreRecentFileList();
}
Window::~Window()
{
saveRecentFileList();
}
void Window::saveRecentFileList()
{
QSettings settings(m_settingsPath, QSettings::NativeFormat);
settings.setValue("recentFiles/list", QVariant(m_recentFilesList));
}
void Window::restoreRecentFileList()
{
QSettings settings(m_settingsPath, QSettings::NativeFormat);
m_recentFilesList = settings.value("recentFiles/list").toStringList();
}
void Window::openFile(QString l_file)
{
if(isValidFile(l_file))
{
m_recentFilesList << l_file;
done(QDialog::Accepted);
qDebug() << "connected to : " << l_file;
}
else
{
QMessageBox::information(this, "Information", "Please choose valid file", QMessageBox::Ok);
}
}
To copy to clipboard, switch view to plain text mode
//when i print m_recentFilesList , i am able to see expected values
on 1st run of Application: no .ini file , after closing App : .ini file have 1 file name stored in it
on 2st run of Application: .ini file have 1 file name stored in it , after closing App : .ini file have 1 file name stored in it
on 1st run of Application: .ini file is empty , ini file is empty
on 1st run of Application: no .ini file , after closing App : .ini file have 1 file name stored in it
on 2st run of Application: .ini file have 1 file name stored in it , after closing App : .ini file have 1 file name stored in it
on 1st run of Application: .ini file is empty , ini file is empty
To copy to clipboard, switch view to plain text mode
Bookmarks