Important: Please read the Qt Code of Conduct -

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"));
     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);
     QWidget *window_A = new QWidget;
     QLabel *label = new QLabel(" ");
     label = new QLabel("<b>Select Profile Name:</b>");
    combo = new QComboBox();

    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

  • Lifetime Qt Champion

    You need full path to file ( with filename)
    Then do
    QFile file (Fullpathtofile);

    so I guess something like
    QString FullFile= templateprofilepath + "/" + FileNameFromCombo

  • @mrjj

    then the FullFile path is looks like this D:\logs/file.xml
    how can i change the path?

  • Lifetime Qt Champion

    just use "\"

    QString FullFile= templateprofilepath + "\\" + FileNameFromCombo
    NOTE: you MUST use 2 of them. 

  • @mrjj
    thanks a lot :)

Log in to reply