PDA

View Full Version : MV(C): how to QListView?



olivier1978
10th February 2013, 00:01
Hi all,

I'm not a Qt newbie but i'm a MVC newbie ...
I'm currently thinking about an app but i'm stucked and do not know how to start. Basically, this app will have a QListView and some tool buttons. What i need, is to display in the QListview files and folders that will need some kind of processing. Of course, tool buttons will help in adding some files and folders for further processing.
I do not know where to start ... Should I derived from QAbstractItemModel? I do not know at app start up how many files/folders will need to be processed. I also want to enable d'n'd in the QListView for a comfortable user experience with this app. Could you please give me some ways to do this?

For the processing, I need to retrieve the full files/folders paths from the QlistView so they can feed an algorithm of my own in a separate thread to avoid unresponsive GUI (I already know how to do that part). What I do not already know is how to populate my QListView with files/folders. This why I'm asking your help.

I already have designed my own .ui with Qt designer but would like to go a step ahead and start implementing that (really simple) app. Any help would be appreciated. Please, do not focus on the d'n'd part, but more on the MV(C) (as from what I(ve read so far, Qt, mixes "V" and "C" ...) and its specific implentation: should I create my own class derived from QAbstractItemModel, whici methods are mandatory, and so on ...

Regards,

Olivier

Santosh Reddy
10th February 2013, 14:38
If you decided on using QListView then yes you have to at-least implement a model (a derived QAbstractItemModel).

If the item count in the list is not large then you could also explore using QListWidget, where you need not implement a model, in fact no new class required. Just create QListWidgetItem and insert in to the QListWidget.

olivier1978
10th February 2013, 16:17
Thanks Santosh :). QListWidget seems to fit my needs. Will give it a try.