QTreeWidget, Subitem must not receive a subitem

20 Views Asked by At

I use a QTreeWidget and there I load/transfer items from a QListWidget or from the QListWidget via drag and drop into the QTreeWidget. The displayed items in my QTreeWidget should not allow me to get a subitem that is already in the tree of an item so that this subitem cannot get any items. Here is an example.

The following should only be possible:

  1. Item1

    • Item2
    • Item3
  2. Item4

  3. Item5

  4. Item6

The following should NOT be possible:

  1. Item1
    • Item2
    • Item3

regardless of the name, in this example Item3 must not become a subitem of Item2 but only a subitem of Item1.

If I now take Item6 or Item5, for example, and drag it onto Item3 and release it, it should look like this

  1. Item1
    • Item2
    • Item3
    • Item6

I also want that when I drag the subitems (Item2,3,6) from Item1 that they are not a subitem of Item1.

I hope it is somewhat understandable my explanation and also hope that someone can help me with it.

I have already tried to solve this via a drag and drop event but so far without success.

0

There are 0 best solutions below