Skip to content

Instantly share code, notes, and snippets.

@lpranam
Created December 12, 2018 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lpranam/c20b75042b7569d2da942bfe69fc26c2 to your computer and use it in GitHub Desktop.
Save lpranam/c20b75042b7569d2da942bfe69fc26c2 to your computer and use it in GitHub Desktop.
This gist is created for Google Code-In 2018 task "Tutorial 2 - Creating a file explorer" of KDE.(https://codein.withgoogle.com/dashboard/tasks/4925281098792960/)

KDE has its own file manager known as Dolphin. This task will make a little familiar with how the file manager works.

Overview of Task: We will create a file explorer which can help you navigate through files on your computer. This program will be able to show you the only name of file and directories and not able to delete open or modify anything.

Prerequisites: Basic knowledge of QT classes QDir, QListWidget and QFileInfo

Steps:

  1. Create new QtWidget project
  2. Now add a new QListWidget into your MainWindow
  3. Now create a class object of QDir in MainWindow class(we will refer this object as "dir")
  4. Create a foreach loop and iterate over drives. This can be achieved with method drives
  5. Inside this loop add a new item in the list as absoluteFilePath of the current file.
  6. Exit loop
  7. Now its time to connect itemDoubleClicked signal of the list with a new custom slot.
  8. In this new slot function, we will have an argument QListWidgetItem. Now we need to set the text of this item as the path of our dir object.
  9. Now clear this list with clear method.
  10. Now again we will loop over all the files and folders with the help of entryInfoList method of dir class.
  11. Add absoluteFilePath of each file to the list.
  12. End loop and End of program

Submission:

  • Link to your repository
  • Video of your working explorer.

If you can not understand any part or solve any problem contact mentor they are always happy to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment