Results 1 to 7 of 7

Thread: [Qt6] StartDrag making crash on Qt6

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanked 86 Times in 81 Posts

    Default Re: [Qt6] StartDrag making crash on Qt6

    Can you please provide a minimal, compilable example so we can reproduce the issue?

    /edit: and are you really sure it worked with 5.15?
    Last edited by ChristianEhrlicher; 12th December 2020 at 18:09.

  2. #2
    Join Date
    May 2013
    Posts
    321
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    9
    Thanked 8 Times in 8 Posts

    Default Re: [Qt6] StartDrag making crash on Qt6

    This code reproduces the issue, you can start to drag and drop "Item1" and you will see a crash immediately once you move the mouse during drag and drop.
    Qt Code:
    1. #include <QApplication>
    2. #include <QDrag>
    3. #include <QListWidget>
    4. #include <QMainWindow>
    5.  
    6. class CustomListWidget : public QListWidget
    7. {
    8. public:
    9. CustomListWidget(QWidget* parent) : QListWidget(parent)
    10. {}
    11.  
    12. protected:
    13. void startDrag(Qt::DropActions supportedActions) override
    14. {
    15. QDrag* drag = new QDrag(this);
    16. drag->setMimeData(mimeData(selectedItems()));
    17. drag->exec(supportedActions);
    18. }
    19. };
    20.  
    21. int main(int argc, char *argv[])
    22. {
    23. QApplication a(argc, argv);
    24. CustomListWidget customListWidget(&w);
    25. customListWidget.setMovement(QListView::Snap);
    26. customListWidget.setViewMode(QListView::IconMode);
    27. customListWidget.setResizeMode(QListView::Adjust);
    28. customListWidget.setSelectionMode(QAbstractItemView::ExtendedSelection);
    29. customListWidget.setDragDropMode(QAbstractItemView::DragDrop);
    30. customListWidget.setDefaultDropAction(Qt::MoveAction);
    31. customListWidget.setIconSize(QSize(64, 64));
    32. customListWidget.setUniformItemSizes(true);
    33. customListWidget.setSortingEnabled(true);
    34. customListWidget.setWrapping(true);
    35. customListWidget.addItem("Item1");
    36. customListWidget.addItem("Item2");
    37. w.show();
    38. return a.exec();
    39. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanked 86 Times in 81 Posts

    Default Re: [Qt6] StartDrag making crash on Qt6

    Thx for the reproducer and as I expected it's just by accident that it does not crash with Qt5. QIconModeViewBase::itemsRect() is called with an empty container due to your custom startDrag() function. The original startDrag() fills this container before calling drag->exec(). Will create a bug report for it.

    /edit: Here the ink to the bugreport: https://bugreports.qt.io/browse/QTBUG-89434
    Last edited by ChristianEhrlicher; 12th December 2020 at 20:42.

  4. #4
    Join Date
    May 2013
    Posts
    321
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    9
    Thanked 8 Times in 8 Posts

    Default Re: [Qt6] StartDrag making crash on Qt6

    Thanks! I added myself as watcher

Similar Threads

  1. On the way of making an app installable
    By franky in forum Newbie
    Replies: 6
    Last Post: 5th February 2017, 10:14
  2. Replies: 0
    Last Post: 3rd November 2015, 17:58
  3. Crash gracefully? No crash!
    By lni in forum Qt Programming
    Replies: 0
    Last Post: 7th July 2010, 03:59
  4. making new project qt4
    By !Ci in forum Qt Programming
    Replies: 1
    Last Post: 18th June 2009, 13:32
  5. Need help making plugin
    By vieraci in forum Qt Programming
    Replies: 10
    Last Post: 24th September 2007, 13:20

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.