Results 1 to 9 of 9

Thread: qlistview drag&drop problem

  1. #1
    Join Date
    Aug 2006
    Posts
    83

    Unhappy qlistview drag&drop problem

    Hello, I have a problem with a qlistview. I have some custom made slides in it and I have a problem with dragging them around qlistview. I enabled the drag&drop on the qlistview like this:
    Qt Code:
    1. //just for reference
    2. //QListView *iconList;
    3. iconList->setDragEnabled(true);
    4. iconList->setViewMode(QListView::IconMode);
    5. iconList->setIconSize(siz);
    6. //iconList->setSelectionMode(QAbstractItemView::SingleSelection);
    7. iconList->setGridSize(isiz);
    8. iconList->setSpacing(inc_size);
    9. iconList->setUniformItemSizes(true);
    10. iconList->setMovement(QListView::Free);
    11. //iconList->setMovement(QListView::Snap);
    12. iconList->setAcceptDrops(true);
    13. iconList->setDropIndicatorShown(true);
    14. iconList->setResizeMode(QListView::Adjust);
    To copy to clipboard, switch view to plain text mode 

    If i start dragging from the top item it shows the marker but it's in the top left position. If i continue dragging (and move outside the widget area and than back -still dragging), the marker appears at the right position and stays that way until i realease the item All of the following dragging continued by the previous dragging is made completely ok (the marker is right where it should be.
    Does anyone have any idea??
    ps. I use this for the drag events... ( if I use qlistview events the result is absolutely awfull...)
    Qt Code:
    1. void MListView::dropEvent(QDropEvent * event) {
    2. //QListView::dropEvent(event);
    3. QAbstractItemView::dropEvent(event);
    4. }
    5.  
    6. void MListView::dragMoveEvent(QDragMoveEvent * event) {
    7. //QListView::dragMoveEvent(event);
    8. QAbstractItemView::dragMoveEvent(event);
    9. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by moowy; 10th October 2006 at 11:04.

  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: qlistview drag&drop problem

    Hmm, sounds like you are mixing two things up; 1) moving items around the list view and 2) drag'n'drop. You don't need drag'n' drop for moving items around the list view:

    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char *argv[])
    4. {
    5. QApplication a(argc, argv);
    6.  
    7. QListView list;
    8. list.setViewMode(QListView::IconMode);
    9. list.setGridSize(QSize(20,20));
    10. list.setMovement(QListView::Snap);
    11.  
    12. QStringListModel model(QStringList() << "a" << "b" << "c");
    13. list.setModel(&model);
    14. list.show();
    15.  
    16. return a.exec();
    17. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 10th October 2006 at 11:09. Reason: Added example
    J-P Nurmi

  3. #3
    Join Date
    Aug 2006
    Posts
    83

    Default Re: qlistview drag&drop problem

    I'm not sure what did u try to achieve with you're test program (i compiled it and the movement doesn't work), but u we're right. I did confuse drag&drop and movement. But I still need both (to move files between different tabs). The problem is still the same (untill I move one element outside the widget I get the movement marker at the wrong place).

  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: qlistview drag&drop problem

    Heh, it indeed doesn't seem to work with 4.1.4 whereas the movement works fine in 4.2.0.
    But there you see how important it is to describe the actual problem.. So the problem was not moving items within a list view, the problem was with drag'n'dropping items between two different list views, right?
    Last edited by jpn; 10th October 2006 at 11:52.
    J-P Nurmi

  5. #5
    Join Date
    Aug 2006
    Posts
    83

    Default Re: qlistview drag&drop problem

    I'll try to upgrade ... You're right, it is vital to address the problem properly. But the problem is the same. The problem is with the actual movement within the same listview and not with the drag&drop. Do you have any ideas how to fix this?
    Last edited by moowy; 10th October 2006 at 12:08.

  6. #6
    Join Date
    Aug 2006
    Posts
    83

    Default Re: qlistview drag&drop problem

    Do you think that I have something wrong with my flags.. ?

    Qt Code:
    1. Qt::ItemFlags MyClass::flags(const QModelIndex &index) const
    2. {
    3. if (index.isValid())
    4. return Qt::ItemIsEnabled | Qt::ItemIsSelectable
    5. | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
    6.  
    7. return Qt::ItemIsEnabled | Qt::ItemIsDropEnabled;/*| Qt::ItemIsSelectable;*/
    8. }
    To copy to clipboard, switch view to plain text mode 

    or with the way I initialize qlistviews gridsize:
    Qt Code:
    1. QSize siz = whiteboard->size;
    2. QSize isiz = siz + QSize(3*inc_size, 3*inc_size);
    3.  
    4. iconList->setIconSize(siz);
    5. iconList->setGridSize(isiz);
    6. iconList->setSpacing(inc_size);
    7. iconList->setUniformItemSizes(true);
    8. iconList->setMovement(QListView::Snap);
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Aug 2006
    Posts
    83

    Default Re: qlistview drag&drop problem

    Ok. I have 1t 4.2.0 up and running. My question still remains: is there any way to draw some kind of marker where the item is being moved while in movement (beside the plus) ??

  8. #8
    Join Date
    Aug 2006
    Posts
    83

    Default Re: qlistview drag&drop problem

    Qt 4.2.0 is absolutely terrible. It isn't ready for the release yet. So my question is next: is there any way to draw something to indicate where the item is being moved inside a qlistview ( like a line or a box maybe ) ??

  9. #9
    Join Date
    Aug 2006
    Posts
    83

    Default Re: qlistview drag&drop problem

    Ok. This thread is turning into a monologe. If anyone can help me I have my latest conclusion on the qlistview movement problem.... Ok I found out that the moving marker is shown for every slide as long as it is inside parent widgets viewport area.
    Example:

    i have 200*400 wide area and the area is abstractscrollarea so it can be bigger than the 200*400 and i just scroll to the right slide. here's the trick, if i move outside 200*400 area (scroll down) the moving marker stops showing and i have nothing showing for the movement.

    Does anyone have any idea??

Similar Threads

  1. Problem with drag&drop in qlistview
    By mambo in forum Qt Programming
    Replies: 2
    Last Post: 11th September 2006, 16:14
  2. QListView & backgroundBrush -> Houston we hv a problem
    By travis in forum Qt Programming
    Replies: 3
    Last Post: 31st July 2006, 07:13
  3. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 12:54
  4. Replies: 16
    Last Post: 7th March 2006, 15:57
  5. Keeping focus at bottom of QListView
    By jakamph in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2006, 14:45

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.