Results 1 to 2 of 2

Thread: Problem with auto expand on treeview

  1. #1
    Join Date
    Apr 2009
    Location
    S-chanf
    Posts
    4
    Qt products
    Platforms
    Unix/X11 Windows

    Question Problem with auto expand on treeview

    Hi,

    I have a custom treemodel and a treeview, with a QSortFilterProxyModel in between (all in PyQt4). It looks like this:


    Now, I want to drag images from the listview (the widget in the middle) to the treeview, but only on second level items (the ones with the colored circles in front of them). I want to use setAutoExpandDelay, so that top level items get expanded when a drag hovers over them. I've got a couple of problems, though:

    1. If I hover over a second level element, Qt apparently tries to expand it, although it has no children. The outline around the hovered item vanishes, and the following error messages are printed:
      Qt Code:
      1. QPainter::begin: Paint device returned engine == 0, type: 2
      2. QPainter::setWorldTransform: Painter not active
      3. QPainter::end: Painter not active, aborted
      To copy to clipboard, switch view to plain text mode 

      My model correctly returns a rowCount of zero, so I have no idea why Qt wants to expand them.
    2. When I hover over a top level item, Qt expands it as expected. But when I hover over a second top level item during the same drag operation, it doesn't get expanded.


    I checked my model with ModelTest, it doesn't detect any errors in my model.

    Here's my treeview, and my tree model

  2. #2
    Join Date
    Apr 2009
    Location
    S-chanf
    Posts
    4
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: Problem with auto expand on treeview

    I worked around my first problem by enabling and disabling autoexpand, depending on the item that is below the mouse during a drag action:

    Qt Code:
    1. def dragMoveEvent(self, event):
    2. item = self.model().proxy_item(self.indexAt(event.pos()))
    3. if hasattr(item, 'query'):
    4. # second level
    5. self.setAutoExpandDelay(-1)
    6. else:
    7. # top level
    8. self.setAutoExpandDelay(500)
    9. QtGui.QTreeView.dragMoveEvent(self, event)
    To copy to clipboard, switch view to plain text mode 

    But that's just gross. And it doesn't solve my second problem. Any other ideas?

Similar Threads

  1. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 10:12
  2. Problem with TreeView
    By init2null in forum Qt Programming
    Replies: 8
    Last Post: 25th May 2008, 10:56

Tags for this Thread

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.