PDA

View Full Version : Some problems with lists



gdiepen
16th January 2008, 10:46
Hi everybody,

currently I am working on a program that acts as a partial activesync replacement under linux. I am writing the program in Python combined with PyQt4 and I am trying to figure out how to get a list widget to look like something Microsoft uses for their ActiveSync. I want to list all partnerships available on the phone (and later on also enable people to modify the partnerships).

The ultimate goal would be the following bottom part of the screen:
http://www.windowsceportal.hu/kepek/programok/78.gif

I am only interested in knowing howto create such a 'tree' like structure where all possible sync-items (Contacts, Calendar, E-mail) belonging to one Sync-Group(Windows PC in this case) are all indented underneath the group, but without the little dotted lines I would get while using a qtreeview.
Furthermore, I am not interested in the second column that is present in the screenshot, only in the listing of all groups with all subitems.

My guess is that I would have to create this some way using a qlistview or so, but I just can't seem to find the right examples/instructions on how to create such a listview.

Could anybody provide some starters for me (preferably python, but c++ should be ok also, i think I can convert it quite easily :) )

jpn
16th January 2008, 10:58
In short, take a look at QTreeView (and QTreeWidget). :)

gdiepen
16th January 2008, 11:01
In short, take a look at QTreeView (and QTreeWidget). :)

But with QTreeView, I always get the dotted lines, representing the parent/child structure. Furthermore, I don't want to have the possibility that people fold a complete group, it must be always shown unfolded.

jpn
16th January 2008, 11:05
But with QTreeView, I always get the dotted lines, representing the parent/child structure.
Try overriding QTreeView::drawBranches() with an empty implementation.


Furthermore, I don't want to have the possibility that people fold a complete group, it must be always shown unfolded.
See QTreeView::itemsExpandable property.

gdiepen
16th January 2008, 11:10
Try overriding QTreeView::drawBranches() with an empty implementation.


See QTreeView::itemsExpandable property.

I will give that a try tonight ;) If it doesn't work or I have more questions, I will let it know ;)

wysota
16th January 2008, 11:16
It will work :)

gdiepen
16th January 2008, 11:49
It will work :)

Famous last words ;)

Since I haven't programmed that much with python and PyQt4 yet, it will take some trying from my side before it will work I guess ;)

gdiepen
16th January 2008, 16:42
The setExpandable for sure did the trick for one part. For this I am really happy ;)

The other answer, your suggestion to override the drawBranches method is what I am currently working on. I don't think that I can just add a QTreeView widget to my window (with qt4-designer) and just override the drawBranches in my Python code. My guess is that I will have to create my own widget for this, in which I override the drawBranches method.

If somebody knows of a really easy way of overriding this function in Python with PyQt4, I would be really grateful for that.

wysota
16th January 2008, 16:53
If somebody knows of a really easy way of overriding this function in Python with PyQt4, I would be really grateful for that.

You have to subclass QTreeView and reimplement drawBranches() in the subclass. Then in Designer right click on your tree view and use the promote feature to promote the widget to your subclass.

gdiepen
16th January 2008, 16:54
The setExpandable for sure did the trick for one part. For this I am really happy ;)

The other answer, your suggestion to override the drawBranches method is what I am currently working on. I don't think that I can just add a QTreeView widget to my window (with qt4-designer) and just override the drawBranches in my Python code. My guess is that I will have to create my own widget for this, in which I override the drawBranches method.

If somebody knows of a really easy way of overriding this function in Python with PyQt4, I would be really grateful for that.

Yes, I got it to work ;)

Just to make sure, if somebody reads this thread he gets all information:

self.myTreeView is a QTreeView Object.

First I define a new function that will take care of the drawBranches, called myDrawBranches

After this, I only have to do: self.treeView.drawBranches = myDrawBranches

And everything is working :D

Thank you guys!!!