Solved how can i delete a file ?
-
Am selecting a file using combobox, combobox has the list of .xml files like this
QSettings oSettings(QLatin1String("Main"),QLatin1String("Sub")); oSettings.setFallbacksEnabled(false); oSettings.beginGroup("dedup"); QStringList files = qVariantValue<QStringList>(oSettings.value("templateprofilepath")); QString strPath_2 = files.join(""); QDir oDir_2(strPath_2); QStringList strFileFilterLst_2; QStringList strLstFiles_2 = oDir_2.entryList(strFileFilterLst_2,QDir::Files | QDir::NoDotAndDotDot); strLstFiles_2.replaceInStrings(".xml", "", Qt::CaseInsensitive); strLstFiles_2.prepend(""); QWidget *window_A = new QWidget; QLabel *label = new QLabel(" "); label = new QLabel("<b>Select Profile Name:</b>"); combo = new QComboBox(); combo->addItems(strLstFiles_2);
templateprofilepath is the location of the dir
now i want to delete the file selected by the combobox , please help me am struck here.Thanks in advance.
sorry for my english
-
Hi
You need full path to file ( with filename)
Then do
QFile file (Fullpathtofile);
file.remove();so I guess something like
QString FullFile= templateprofilepath + "/" + FileNameFromCombo -
then the FullFile path is looks like this D:\logs/file.xml
how can i change the path? -
just use "\"
QString FullFile= templateprofilepath + "\\" + FileNameFromCombo NOTE: you MUST use 2 of them.
-
@mrjj
thanks a lot :)