Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved QFileDialog: Select file only from a pre-defined directory

    General and Desktop
    qt5.5 file dialog file navigation
    2
    2
    1018
    Loading More Posts
    • 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
      Ankit.Jain last edited by

      Hi,
      I am looking to select a file (of specified type) from a predefined folder. The idea is to not allow the user to browse; just see the files available in the folder and allow him/her to choose from them. I created a basic implementation for the same using QFileDialog, but have been unable to prevent the user from browsing the file system to search for the file.

      Any help would be much appreciated.
      Thanks

      1 Reply Last reply Reply Quote 0
      • Chris Hennes
        Chris Hennes last edited by Chris Hennes

        I would be inclined to not use QFileDialog for that task -- it's designed to look and function the way users expect a file selection dialog to work, which includes navigation. I have a similar use-case in a program I'm currently working on, and my solution was to create a very simple custom dialog that simply presents a list of the files they are allowed to select from. It's very easy to get that list from a QDir and drop that QStringList into a QListWidget.

        Chris Hennes, Pioneer Library System

        1 Reply Last reply Reply Quote 1
        • First post
          Last post