I currently have the filepath of the file that I want to access as a string, but I'm not sure if Qt has a feature that allows you to access that file with only the filepath.
I'm saving the filepath to an INI file and I want to take that filepath to open the json file that is a part of that path. This is what I've tried so far - the code would go into openFile()
void saveFileLocation(QString filename)
{
QSettings *settings = new QSettings(Ve::Widgets::SettingsWindowWidget::INI_FILE, QSettings::IniFormat);
QDir dir;
QString filePath = dir.filePath(filename);
settings->setValue("projectFile", filePath);
on_menuRecent_Files_aboutToShow(filePath);
}
void openFile(QString filepath)
{
*insert code here*
}
void on_menuRecent_Files_aboutToShow(QString filePath)
{
QAction* openAction = ui->menuRecent_Files->addAction(filePath);
connect(openAction, SIGNAL(triggered()), this, SLOT(openFile(filePath)));
}
I want to implement an action option, that has text of the filepath, and when clicked, opens up the file that I want to access. Is there a Qt feature that allows you to do this?
saveFileLocation()is leaking thesettingsobject. You don't really need to usenewat all in that code, but if you do use it, you need todeletewhat younew.Qtsupports both options that @MatteoItalia mentioned.