Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. QFileDialog: Filter directory to include only filenames in QStringList
Forum Updated to NodeBB v4.3 + New Features

QFileDialog: Filter directory to include only filenames in QStringList

Scheduled Pinned Locked Moved Unsolved Qt WebKit
2 Posts 2 Posters 729 Views
  • 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.
  • A Offline
    A Offline
    anshah
    wrote on last edited by anshah
    #1

    Hello Qt Team,
    In QFileDialog, I want to filter by the filenames that are included in a QStringList.

    Example:
    QStringList: ["file1.txt", "file2.txt", ...., fileN.txt]

    QFileDialog should display: "file1.txt", "file2.txt", ...., "fileN.txt"

    I have seen examples for filters like such:

    QString selfilter = tr("JPEG (*.jpg *.jpeg)");
    QString fileName = QFileDialog::getOpenFileName(
            this,
            title,
            directory,
            tr("All files (*.*);;JPEG (*.jpg *.jpeg);;TIFF (*.tif)" ),
            &selfilter 
    );
    

    I just want to display the filenames in the QStringList and I also want to restrict the user to view only to the directory the QFileDialog is initialized to so they should not be able to navigate elsewhere.

    JonBJ 1 Reply Last reply
    0
    • A anshah

      Hello Qt Team,
      In QFileDialog, I want to filter by the filenames that are included in a QStringList.

      Example:
      QStringList: ["file1.txt", "file2.txt", ...., fileN.txt]

      QFileDialog should display: "file1.txt", "file2.txt", ...., "fileN.txt"

      I have seen examples for filters like such:

      QString selfilter = tr("JPEG (*.jpg *.jpeg)");
      QString fileName = QFileDialog::getOpenFileName(
              this,
              title,
              directory,
              tr("All files (*.*);;JPEG (*.jpg *.jpeg);;TIFF (*.tif)" ),
              &selfilter 
      );
      

      I just want to display the filenames in the QStringList and I also want to restrict the user to view only to the directory the QFileDialog is initialized to so they should not be able to navigate elsewhere.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @anshah said in QFileDialog: Filter directory to include only filenames in QStringList:

      I just want to display the filenames in the QStringList

      I don't believe you can do that.

      To stay in one directory and only offer a passed-in list of filenames is not the job for a QFileDialog. You might just as well just present the user with a list of those filenames to pick from, and you don't need to bother showing a directory because you don't want the user to change it or navigate elsewhere.

      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