Results 1 to 4 of 4

Thread: Drag and Dropping items in QTreeView

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Drag and Dropping items in QTreeView

    If the event propagates from the view to the parent widget, it's coordinates are mapped to the coordinates of the parent widget whereas if you call any of the view's methods (like indexAt) it expects the coordinates to be in either the view's or the view's viewport (depending on the method) coordinate space. So you first have to map those coordinates using the family of mapTo*/mapFrom* methods.

    And with all do respect to your C++ skills think if exposing the internal representation of the tree and handling internal affairs of the tree in some external place (like the MainWindow class) is a good design decision of a skilled C++ developer.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Dec 2010
    Posts
    76
    Thanks
    13
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Exclamation Re: Drag and Dropping items in QTreeView


    And with all do respect to your C++ skills think if exposing the internal representation of the tree and handling internal affairs of the tree in some external place (like the MainWindow class) is a good design decision of a skilled C++ developer.
    I am very new to Qt Programming and this is my first professional experience with Qt GUI programming (First programming job period to be exact). I work for a very small company so I pretty much have had to learn Qt on the fly and so that is why the code is pretty rough and my understanding of Qt GUI programming isn't the greatest. What would be a better design approach? Thanks for any help and keep the criticism as it is the only way I will get better.

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

    Default Re: Drag and Dropping items in QTreeView

    This was a C++ related comment not a Qt related one. I would definitely try to handle the drag&drop mechanism in the view object. And would definitely get rid of the getItem() method in the tree.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 2
    Last Post: 20th August 2010, 05:18
  2. Replies: 1
    Last Post: 27th February 2010, 11:39
  3. Catch drag and drop items
    By nina1983 in forum Qt Programming
    Replies: 1
    Last Post: 23rd July 2008, 17:24
  4. drag/dropping outside app
    By musikit in forum Qt Programming
    Replies: 4
    Last Post: 29th February 2008, 17:34
  5. Drag & drop items on the same QTreeView
    By wind in forum Qt Programming
    Replies: 2
    Last Post: 11th October 2006, 14:29

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
  •  
Qt is a trademark of The Qt Company.