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. QTreeView drag & drop issue
Forum Updated to NodeBB v4.3 + New Features

QTreeView drag & drop issue

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 4.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.
  • M Offline
    M Offline
    marcus.fr
    wrote on last edited by
    #1

    Hi

    I use QTreeView+QStandardItemModel to create multi column tree widget, with Qt 4.7 libs.

    The [Company] column has items that behave as parent in order to create a group of companies under a particular city.

    @
    Columns:
    Company |Website |Phone

    +City X
    --Company A|exampleA.com|phone A
    --Company B|exampleB.com|phone B
    --Company C|exampleC.com|phone C
    +City Y
    --Company D|exampleD.com|phone D
    --Company E|exampleE.com|phone E
    --Company F|exampleF.com|phone F
    @

    The default drop action is MoveAction. I want to drag row from one group to another, say to move Company F into City X group.

    When I drag [Company F] item it can as well be dropped in [Phone B] item in group City X. This action moves the row to another group but it is shifted on the right, [Company F] item starts in the [Phone] column.

    To avoid this I set setDragEnabled(false) and setDropEnabled(false) to all items except those in the first column [Company];

    Again it is allowed to drop/move [Company] item into [Phone] column of another row.

    Any suggestions?

    [EDIT: code formatting for ASCII art, Volker]

    1 Reply Last reply
    0
    • M Offline
      M Offline
      marcus.fr
      wrote on last edited by
      #2

      Any opinions whether this is a bug?

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        No, it's not a bug. Per default you can drag any item and drop it anywhere. My experience taught me to handle the drag and drop stuff manually, and not rely on the built-in methods, if you have constraints on where a drop can occur.

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • M Offline
          M Offline
          marcus.fr
          wrote on last edited by
          #4

          [quote author="Volker" date="1328914895"]No, it's not a bug. Per default you can drag any item and drop it anywhere. [/quote]

          What's the use of QStandardItem::setDropEnabled then? When this is set to false the item still accepts drops.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            [quote author="Marcus Frenkel" date="1328951033"]
            What's the use of QStandardItem::setDropEnabled then? When this is set to false the item still accepts drops.[/quote]

            Sorry, I don't know that. We never used the standard item models in our projects together with DnD.

            http://www.catb.org/~esr/faqs/smart-questions.html

            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