I'm not sure what you want to achieve. You can always create a "saveFile" function taking a QString as parameter and call it with different arguments:
void Dialog::saveFile(const QString& path)
{
...
}
//
void Dialog::saveValue()
{
QString path
="/home/pi/valueHSV/hsv.xml";
this->saveFile(path);
QString differentPath
="/home/pi/valueHSV/another.xml";
this->saveFile(differentPath);
...
}
void Dialog::saveFile(const QString& path)
{
QFile valueHSV(path);
valueHSV.open(QIODevice::WriteOnly);
...
}
//
void Dialog::saveValue()
{
QString path="/home/pi/valueHSV/hsv.xml";
this->saveFile(path);
QString differentPath="/home/pi/valueHSV/another.xml";
this->saveFile(differentPath);
...
}
To copy to clipboard, switch view to plain text mode
If you want to manually select the save file path, you can use QFileDialog:
void Dialog::saveValue()
{
"/home/my_path/",
tr("Xml Files(*.xml)");
if (!path.isEmpty()){
...
}
}
void Dialog::saveValue()
{
QString path=QFileDialog::getSaveFileName(this, tr("Save File"),
"/home/my_path/",
tr("Xml Files(*.xml)");
if (!path.isEmpty()){
QFile valueHSV(path);
valueHSV.open(QIODevice::WriteOnly);
...
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks