Results 1 to 4 of 4

Thread: How to highlight (or) draw on drop target item, when a drag is active??

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2008
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question How to highlight (or) draw on drop target item, when a drag is active??

    Greetings!

    I have a treeview and all its columns are delegated.

    Requirement:- When I drag a row and try to drop it to another row, I want to show some indication in target row either by drawing a rectangle (highlighting the target row).

    In the constructor of the delegate, the event filter has been installed.

    QTreeView* pTreeView = dynamic_cast<QTreeView*>(parent); //parent is treeview
    pTreeView->viewport()->installEventFilter(this);

    And in the eventFilter of this delegate (derived from QStyledItemDelegate), I could catch the MouseMove (or) DragMove event. Also I can get the mouse position and the index on which the cursor is present.

    Issue:- With the mouse position, I am trying to draw a rectangle in the paint function. BUT WHEN THE DRAG IS ACTIVE, THE PAINT METHOD IS NOT GETTING CALLED.

    It would be great, if somebody throw some light on this issue... Why the paint is not getting called? Is there any other approach to tackle this issue.

    P.S: I vastly searched this forum. Two of them had exact issue, but no answer for this.

    Regards

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to highlight (or) draw on drop target item, when a drag is active??

    Check the Puzzle example in Qt Demos.
    Qt Demos \ Item Views \ Puzzle.

    It has similar working to your requirement.

  3. #3
    Join Date
    Sep 2008
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to highlight (or) draw on drop target item, when a drag is active??

    I checked that, before I raised question in this forum.
    That example is demonstrated in a widget. The drag and paint events are there in the widget itself.

    In my scenrio, I have a treeview and all the columns are delegated. When a tree item is dragged, behind the scene the paint method in delegate is not getting called. Once I drop it, the paint is called...

  4. #4
    Join Date
    Sep 2008
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to highlight (or) draw on drop target item, when a drag is active??

    I found some useful thread which helps me to attack my problem.

    http://www.qtcentre.org/threads/2829...drop-revisited

    Basically we need to emit layoutChanged signal in dropMoveEvent.

Similar Threads

  1. Replies: 3
    Last Post: 10th June 2010, 16:13
  2. Replies: 1
    Last Post: 18th November 2008, 07:57
  3. Active Directory and Qt
    By chak_med in forum Qt Programming
    Replies: 1
    Last Post: 6th December 2006, 20:54
  4. active child
    By evgenM in forum Qt Programming
    Replies: 3
    Last Post: 22nd May 2006, 13:16
  5. Painter not active!
    By Caius Aérobus in forum Qt Programming
    Replies: 7
    Last Post: 30th March 2006, 16:44

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.