Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QListView: Drag item disappears
Forum Updated to NodeBB v4.3 + New Features

QListView: Drag item disappears

Scheduled Pinned Locked Moved General and Desktop
15 Posts 4 Posters 4.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    repoman
    wrote on last edited by
    #1

    Hi,

    Was this issue ever solved?

    https://bugreports.qt-project.org/browse/QTBUG-1180

    Still, with Qt 4.7.4, If I set up a simple QListVIew in icon mode, the item (text and icon) disappears when the dragged item reaches the border of the viewport. Also, in the position where the drag icon normally is displayed, only a small dotted rectangle border appears.

    Here's a small example:

    @#include <QtGui>

    #include <QListView>
    #include <QStandardItemModel>
    #include <QWidget>

    class Widget : public QWidget
    {
    Q_OBJECT

    public:
    Widget(QWidget *parent = 0);

    private:
    QListView *view;
    QStandardItemModel *model;
    };

    Widget::Widget(QWidget *parent)
    : QWidget(parent)
    {
    QHBoxLayout *layout = new QHBoxLayout;
    setLayout(layout);

    view = new QListView;
    layout->addWidget(view);
    
    view->setDragEnabled(true);
    view->setViewMode(QListView::IconMode);
    view->setIconSize(QSize(60, 60));
    view->setSpacing(10);
    view->setAcceptDrops(true);
    view->setDropIndicatorShown(true);
    
    model = new QStandardItemModel(this);
    for (int i=0; i<5; ++i)
    {
        QStandardItem *item = new QStandardItem(QString("Item %0").arg(i));
        model->appendRow(item);
    }
    
    view->setModel(model);
    

    }

    @

    1 Reply Last reply
    0
    • U Offline
      U Offline
      unixmania
      wrote on last edited by
      #2

      just an idea:
      @
      view = new QListView(parent or this);
      QHBoxLayout *layout = new QHBoxLayout(parent or this);
      @

      1 Reply Last reply
      0
      • R Offline
        R Offline
        repoman
        wrote on last edited by
        #3

        The correct reparenting of the layout and the view is taken care of automatically by the respective calls to setLayout and addWidget. In other words, I believe the code above is correct.

        1 Reply Last reply
        0
        • R Offline
          R Offline
          repoman
          wrote on last edited by
          #4

          I tried with 4.8.5 and there the "problem" is the same.

          You may also try to run the puzzle example in

          qt-everywhere-opensource-src-4.8.5/examples/itemviews/puzzle

          When the jigsaw piece reaches the border of the view it disappears. During the entire drag, the drag cursor looks strange with an empty dotted rect underneath the cursor.

          Is this really expected behavior?

          1 Reply Last reply
          0
          • R Offline
            R Offline
            repoman
            wrote on last edited by
            #5

            I can see that this post apparently draws very little attention.

            I would still be very happy if somebody can tell me if the behavior that I report above for the puzzle example is intended.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi and welcome to devnet,

              I just tested it with Qt 5 and it's still the same behavior. Whether intended or not, I don't know, but since there's an open bug report, i would say no

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • P Offline
                P Offline
                pkj__
                wrote on last edited by
                #7

                Yes it is a bug. And it is unresolved :(

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  repoman
                  wrote on last edited by
                  #8

                  Thanks for the replies.

                  In other words:

                  If you want a full-blown icon mode ListView and proper DnD support, you basically have to implement the whole thing yourself:

                  startDrag() with custom pixmaps for QDrag and the usual methods for the relevant model.

                  Is that the correct path and is it doable?

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Bug fix is on its way

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      repoman
                      wrote on last edited by
                      #10

                      You have no idea have happy you just made me. Thanks a bunch!

                      Will you drop a note when it's there? Will it be Qt 5 only?

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        Sure I will, you can also watch the bug report to see when it's done.

                        No, I'll try to fix it for both. Qt 5 will need some more work.

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • R Offline
                          R Offline
                          repoman
                          wrote on last edited by
                          #12

                          Great - thanks!

                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

                            Hi,

                            The bug has been fixed for 4.8.6 and 5.2.0

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            0
                            • R Offline
                              R Offline
                              repoman
                              wrote on last edited by
                              #14

                              Great - and thanks!

                              Any idea when 4.8.6 will be released?

                              1 Reply Last reply
                              0
                              • SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on last edited by
                                #15

                                You're welcome !

                                Sorry I don't know

                                Interested in AI ? www.idiap.ch
                                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                1 Reply Last reply
                                0

                                • Login

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • Users
                                • Groups
                                • Search
                                • Get Qt Extensions
                                • Unsolved