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 stop working on new Qt versions
Qt 6.11 is out! See what's new in the release blog

QListView stop working on new Qt versions

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 424 Views 2 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.
  • A Offline
    A Offline
    AlexNevskiy
    wrote on last edited by AlexNevskiy
    #1

    I have the next code

    #include <QFont>
    #include <QApplication>
    #include <QListView>
    #include <QStandardItemModel>
    
    class MyModel : public QStandardItemModel
    {
    public:
        Qt::ItemFlags flags(const QModelIndex &index) const override
        {
            Q_UNUSED(index);
            return Qt::ItemIsSelectable
                    | Qt::ItemIsEditable
                    | Qt::ItemIsDragEnabled
                    | Qt::ItemIsEnabled;
        }
    };
    
    //------------------------------------------------------------------------------
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        a.setFont({"Verdana", 16});
    
        MyModel model;
        auto style = a.style();
        model.appendRow(new QStandardItem(style->standardIcon(QStyle::SP_DialogCancelButton), "cancel"));
        model.appendRow(new QStandardItem(style->standardIcon(QStyle::SP_FileDialogInfoView), "info"));
        model.appendRow(new QStandardItem(style->standardIcon(QStyle::SP_DialogOpenButton), "open"));
        model.appendRow(new QStandardItem(style->standardIcon(QStyle::SP_DialogSaveButton), "save"));
        model.appendRow(new QStandardItem(style->standardIcon(QStyle::SP_DialogOkButton), "ok"));
    
        QListView list;
        list.show();
        list.resize(700, 500);
        list.setModel(&model);
        list.setIconSize({64, 64});
        list.setViewMode(QListView::IconMode);
        list.setWrapping(false);
        list.setResizeMode(QListView::Fixed);
        list.setMovement(QListView::Snap);
        list.setGridSize({128, 128});
        list.setSelectionBehavior(QAbstractItemView::SelectItems);
        list.setSelectionMode(QAbstractItemView::ExtendedSelection);
    
        list.setDragDropMode(QListView::DragDrop);
        list.setAcceptDrops(true);
        list.setDefaultDropAction(Qt::MoveAction);
        list.setDragDropOverwriteMode(false);
        list.showDropIndicator();
    
        return a.exec();
    }
    
    

    In Qt 5.13.2 (MinGW) it works very well. I can move items in list similiarly like icons on the OS Windows desktop with snapping to grid. But in Qt 5.15.2 (edited) items have become undraggable and unmovable with the same code. The same is true for Qt 6.1.0 - the newest version of Qt. Was there some changes happened in QListView behaviour?

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

      Hi,

      Can you check with a version more recent if 5.12 ? If memory serves well they should be around .12.

      Do you have the same issue with the latest 5.15 ?

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

      A 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Can you check with a version more recent if 5.12 ? If memory serves well they should be around .12.

        Do you have the same issue with the latest 5.15 ?

        A Offline
        A Offline
        AlexNevskiy
        wrote on last edited by
        #3

        @SGaist Hello. I'm sorrow, there's a typo in this moment. I meant not 5.12.2 version, but 5.15.2 - more later version than 5.13.2.

        1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by Christian Ehrlicher
          #4

          With Qt5.15.0 (opensuse leap 15.2) I can freely place the icons, with 5.15.2dev (latest free git source) I can reproduce the issue. Also reproducible with 6.0.3. Maybe I will find some time to investigate further. In the meantime please fill a bug report and post a link here -> bugreports.qt.io

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          A 1 Reply Last reply
          2
          • Christian EhrlicherC Christian Ehrlicher

            With Qt5.15.0 (opensuse leap 15.2) I can freely place the icons, with 5.15.2dev (latest free git source) I can reproduce the issue. Also reproducible with 6.0.3. Maybe I will find some time to investigate further. In the meantime please fill a bug report and post a link here -> bugreports.qt.io

            A Offline
            A Offline
            AlexNevskiy
            wrote on last edited by AlexNevskiy
            #5

            @Christian-Ehrlicher
            Ok. Thank you.
            The link to issue report https://bugreports.qt.io/browse/QTBUG-94226

            1 Reply Last reply
            2

            • Login

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