PDA

View Full Version : [NewBe] A Contact List with QTreeView or Widget



comuun
1st November 2013, 21:49
Hello Qt Centre Community,

I'm new to the whole Qt-Framework and although I've read countless tutorials
I haven't found where to really begin when trying to do what I want to do.

What I want to do is implement a QTreeView to display my contact-list, but
change the whole appearance of the Tree/List.

To really customize the whole thing i have come to the (possibly wrong)
conclusion that I will need delegates and/or override the print event.

But I have no clue as to where to start. I realized that it isn't the smartest
move to try to create my custom contact list and learning how to
work with delegates and print events at the same time, but rather
start learning that first and doing my own thing later.

My questions I guess are thus:

Do I need both delegates and the print event to make a contact list that lists more than an icon and a string in one entry and expends an item to view a little bit more (or embiggen the icon) when it is selected?
I want different behavior in parent and child items (e.g. indentation)
Is QTreeView the right Widget to customize or does QListView have Child and Parent Nodes that you can collapse and expand too? Which one of the two (or possibly a completely other solution) should i use?
What should I learn first and whats the best source/tutorial to learn that specific topic and the implementation?
How should I use the stuff that I need first in order to grasp the theory completely?


I realize that some might think those questions signs of laziness, and unwillingness to research.
But I really don't know where to start first and what i really need to make what I want :(

So please be patient with me and try to help me out a little.

(With my qt knowledge base being what it is at the moment i could realize the whole project right here and now, but
it wouldn't look good and miss a lot of functionality that i wish it to have. I just want to do as much as possible
right from the start, so that I won't have to rework as much later on)

Kind regards, comuun




EDIT: Omg sorry, for some reason either my brain didn't want to see the newbie section on this board!! Could someone be so kind as to move the thread into the right section? Thanks a million :)

EDIT2: I read somewhere that QToolBox might be a good solution, too? I really don't know wether i should use ToolBox TreeView ListView and whatnot :'(

anda_skoa
2nd November 2013, 09:39
You probably won't have to touch QTreeView::paintEvent() unless you need to change how the tree visuals are painted.
You will need delegates to change how the cells/rows are rendered.

QTreeView is very likely the right approach when displaying a unknown amount of data in a tree like structure but you could also have a look at QColumnView which displays tree like data in a "drill-down" kind of fashion.

My suggestion would be to start with learning how to handle the QPainter API but by using simple QWidget painting first.
I.e. create a custom widget and implement paintEvent()

Once you have reach a state where you are satisfied with the visualization, you can easily take that into delegates and are then free to concentrate on the delegate and model/view specific things.

Cheers,
_

comuun
2nd November 2013, 19:01
Thank you for taking the time to read my long question
and thank you even more for giving such a wonderful answer!

Like you said I will concentrate on the QPainter API first
and move on to Delegates afterwards.

I finally how to approach the problem. :)
Thank you!!

ChrisW67
2nd November 2013, 20:12
QColumnView... How, after all this time, have I nver noticed that before? Thanks anda_skoa.