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. QTreeWidget with selective InternalMove
Forum Updated to NodeBB v4.3 + New Features

QTreeWidget with selective InternalMove

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 939 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.
  • D Offline
    D Offline
    divide
    wrote on last edited by
    #1

    Hi,

    I'd like to create a QTreeViewWidget to show virtual folders and data items which would allow intern moves (QAbstractItemView::InternalMove), so that the user could drag the folders and data items between the folders freely.
    However, with the default behaviour if I enable InternalMove, dragging a data1 item over another data2 item will make the data2 item act as a folder (with data1 becoming a child of data2), where it shouldn't. Only folder can embbed folder and data items.
    So it should be very similar to a Folder/File system, but I have no idea how to tell Qt that my data items cannot accept sub items.
    How can I do that ?

    thanks !

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

      Hi
      You could override
      http://doc.qt.io/qt-5/qabstractitemmodel.html#flags
      and only flag some for Qt::ItemIsDropEnabled
      So when a "file" it will not accept other file dropped to it.

      1 Reply Last reply
      1
      • D Offline
        D Offline
        divide
        wrote on last edited by
        #3

        Thanks, would it still allow the data items to be reorganized?
        Moved up/down within the same folder, for example?

        mrjjM 1 Reply Last reply
        0
        • D divide

          Thanks, would it still allow the data items to be reorganized?
          Moved up/down within the same folder, for example?

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @divide
          I think it would. It would only forbid to
          drop directly on an other item.
          Its pr item flag. Liek to allow edit only some etc.
          disclaimer: I never tried it, with your use case.

          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