Results 1 to 17 of 17

Thread: Drag & drop with model/view (Qt4)

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,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Drag & drop with model/view (Qt4)

    You need to remplement mouse events and rendering-related methods (which in practice makes up most if not all of the view code).
    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
    Jun 2010
    Posts
    15
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Drag & drop with model/view (Qt4)

    In very simple case, in current default implementation, to implement row moving inside one table,
    what is the best approach with functions removeRows and insertRows?
    Could I use them directly one after another inside dropMimeData?
    So I can pack in MIME number of line of dragged item and inside dropMimeData I retrieve number of drop line.

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

    Default Re: Drag & drop with model/view (Qt4)

    Quote Originally Posted by Nickolay View Post
    what is the best approach with functions removeRows and insertRows?
    Could I use them directly one after another inside dropMimeData?
    I would say it is better to use QAbstractItemModel::beginMoveRows() and QAbstractItemModel::endMoveRows() in this case. In a general case dropMimeData() would only insert rows and rows removal would be done in the code when the drag is started when a "move" operation is detected.
    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.


  4. #4
    Join Date
    Jun 2010
    Posts
    15
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Drag & drop with model/view (Qt4)

    I'm not clearly understand what do you mean.
    generally I didn't get what sense of QAbstractItemModel::beginMoveRows() and QAbstractItemModel::endMoveRows()

    By docs I should use them from removeRows, like

    bool TableModel::removeRows(int position, int rows, const QModelIndex& index)
    {
    Q_UNUSED(index);
    beginRemoveRows(QModelIndex(), position, position + rows - 1);
    endRemoveRows();
    return true;
    }

    But dragging begins from const func mimeData, where I can't call non const method.

    and rows removal would be done in the code when the drag is started when a "move" operation is detected.
    Where that place you have mentioned?
    Last edited by Nickolay; 19th September 2011 at 20:37.

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

    Default Re: Drag & drop with model/view (Qt4)

    I suggest you read a little about model-view framework in Qt. Everything should become clearer then. One hint -- drag and drop in Qt is handled in the model and not in the view.
    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: 1
    Last Post: 8th January 2009, 17:40
  2. drag and drop QToolButton in QToolBar
    By NBilal in forum Qt Programming
    Replies: 1
    Last Post: 28th December 2008, 20:11
  3. Change cursor & status during Drag & Drop
    By ronlongo in forum Qt Programming
    Replies: 0
    Last Post: 1st December 2008, 16:56
  4. Drag & Drop when parent and childs accept drops?
    By gri in forum Qt Programming
    Replies: 0
    Last Post: 17th October 2008, 09:00
  5. Drag and drop revisited
    By Big Duck in forum Newbie
    Replies: 2
    Last Post: 30th June 2006, 16:41

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.