Results 1 to 10 of 10

Thread: Some problems with lists

  1. #1
    Join Date
    Jan 2008
    Posts
    15
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Some problems with lists

    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:


    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 )

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Some problems with lists

    In short, take a look at QTreeView (and QTreeWidget).
    J-P Nurmi

  3. #3
    Join Date
    Jan 2008
    Posts
    15
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Some problems with lists

    Quote Originally Posted by jpn View Post
    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.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Some problems with lists

    Quote Originally Posted by gdiepen View Post
    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.
    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    gdiepen (16th January 2008)

  6. #5
    Join Date
    Jan 2008
    Posts
    15
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Some problems with lists

    Quote Originally Posted by jpn View Post
    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

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Some problems with lists

    It will work

  8. #7
    Join Date
    Jan 2008
    Posts
    15
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Some problems with lists

    Quote Originally Posted by wysota View Post
    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

  9. #8
    Join Date
    Jan 2008
    Posts
    15
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Some problems with lists

    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.

  10. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Some problems with lists

    Quote Originally Posted by gdiepen View Post
    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.

  11. #10
    Join Date
    Jan 2008
    Posts
    15
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Some problems with lists

    Quote Originally Posted by gdiepen View Post
    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

    Thank you guys!!!

Similar Threads

  1. canonicalFilePath() thread problems
    By magland in forum Qt Programming
    Replies: 10
    Last Post: 5th December 2007, 21:22
  2. Replies: 2
    Last Post: 8th March 2007, 22:22
  3. Problems building mysql plugin for Qt 4.1.2 on windows XP
    By Philip_Anselmo in forum Installation and Deployment
    Replies: 3
    Last Post: 17th May 2006, 15:38
  4. QT4 Plugins - problems, problems
    By NormanDunbar in forum Qt Programming
    Replies: 6
    Last Post: 9th May 2006, 15:39
  5. Array of linked lists
    By therealjag in forum General Programming
    Replies: 9
    Last Post: 9th March 2006, 18:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.