Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how can i delete a file ?
Forum Updated to NodeBB v4.3 + New Features

how can i delete a file ?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • srikanthS Offline
    srikanthS Offline
    srikanth
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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

      srikanthS 1 Reply Last reply
      3
      • mrjjM mrjj

        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

        srikanthS Offline
        srikanthS Offline
        srikanth
        wrote on last edited by
        #3

        @mrjj

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

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          just use "\"

          QString FullFile= templateprofilepath + "\\" + FileNameFromCombo
          NOTE: you MUST use 2 of them. 
          
          srikanthS 1 Reply Last reply
          3
          • mrjjM mrjj

            just use "\"

            QString FullFile= templateprofilepath + "\\" + FileNameFromCombo
            NOTE: you MUST use 2 of them. 
            
            srikanthS Offline
            srikanthS Offline
            srikanth
            wrote on last edited by
            #5

            @mrjj
            thanks a lot :)

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved