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 icons movement
Forum Updated to NodeBB v4.3 + New Features

QListView icons movement

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.1k 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.
  • C Offline
    C Offline
    chabo
    wrote on 28 Apr 2016, 10:22 last edited by A Former User 5 Sept 2016, 11:13
    #1

    I would like to forbid movement of icons in the view but dragging to other views should stay enabled. Is there a way to achieve this?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 28 Apr 2016, 10:34 last edited by
      #2

      Hi
      setAcceptDrops(false);
      might do it.
      Else DragDropMode set to DragOnly

      1 Reply Last reply
      0
      • C Offline
        C Offline
        chabo
        wrote on 28 Apr 2016, 10:53 last edited by chabo
        #3

        Hi,
        sorry, I didn't mention it, but dropping to view should be enabled.
        I have QListView attached to QFileSystemModel. I would like to drag&drop files from/to this view, but I I want to forbid moving of icons within the view only(changing their positions in view).

        possible solution could be: returns icon to its original position if it was dropped to the same view and it was not dropped to some element(I want overwrite file if it was dropped to other file or copy file to folder if it was dropped to folder)

        M 1 Reply Last reply 28 Apr 2016, 10:58
        0
        • C chabo
          28 Apr 2016, 10:53

          Hi,
          sorry, I didn't mention it, but dropping to view should be enabled.
          I have QListView attached to QFileSystemModel. I would like to drag&drop files from/to this view, but I I want to forbid moving of icons within the view only(changing their positions in view).

          possible solution could be: returns icon to its original position if it was dropped to the same view and it was not dropped to some element(I want overwrite file if it was dropped to other file or copy file to folder if it was dropped to folder)

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 28 Apr 2016, 10:58 last edited by
          #4

          @chabo said:
          If you have override then dropEvent/dropEnter
          you can check for the source of the event.
          if event->source() == this then reject
          else accept
          Yes same as your idea, but just forbid the actual drop so
          no need moving it back.

          1 Reply Last reply
          0
          • C Offline
            C Offline
            chabo
            wrote on 28 Apr 2016, 13:56 last edited by
            #5

            Thank you very much.

            void MyListView::dropEvent(QDropEvent * event)
            {
              if (event->source() != this || indexAt(event->pos()).isValid())
              {
                QListView::dropEvent(event);
              }
            }
            
            1 Reply Last reply
            2

            1/5

            28 Apr 2016, 10:22

            • Login

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