Search code examples
qtmodel-view-controllermethodology

Learning Qt: Which methodology to be used for this "advanced UI"?


I am learning Qt5 using PyQt. My goal is to create a UI with several goals (I will base my need on the screenshot below). So here are my goals:

My need

  1. Add directories to a list of directories to be scanned (I know how to use QFileDialog.getExistingDirectory for that). For this I'd like to have a "+" button. When pressed the QFileDialog would open and a new row would be added.

  2. Then I would scan the directory to look for files. It won't be my first implementation but I'd like to have a circular progress bar being displayed during the scan (at the place of the classic progress bar).

  3. When the scan is done, the UI would display the number of files found during the scan. And the progress bar would be replaced by a tick mark icon (not shown on the screenshot...).

  4. At the beginning of each row, I'd like to have a "-" button to delete the row.

UI

My goal is to learn

This is important, I know I am not the first one to have the idea of such a UI. So I not looking for a third party lib on top of Qt. My goal is to learn Qt5 (with PyQt) with this example. But if its unrealistic, please tell me!

My knowledge

  • Mode View: I implemented some basic model view widgets to display strings, and I understand how to extend the idea to tables or trees. In this case the number of rows in the table would be handled automatically. But is it possible to created a table that would display not only strings but also widgets?

  • Widget Mapper: I read that another methodology is the QDataWidgetMapper. In this case, I would have to deal with creation of news rows by myself, and then I would map data onto them. But it seems to be a hard and long job. So, is it a good idea?

So finally could someone tell what is the best direction for that? I am not looking for code, but since it takes a lots of time to learn new concepts, I'd like to learn and use the correct one before starting coding.

Thank you for your help :)!


Solution

  • After so more searches, I found that I need to use the delegate methodology. In Qt5 it's QStyledItemDelegate and in Qt4 it's QItemDelegate. I could find a nice tutorial at the moment, but I started coded it.