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/Model drop action - no expand sign ?
Forum Update on Monday, May 27th 2025

QTreeView/Model drop action - no expand sign ?

Scheduled Pinned Locked Moved Solved General and Desktop
qabstractitemmoqtreeviewqdragqdrop
3 Posts 2 Posters 810 Views
  • 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
    Dariusz
    wrote on 17 Mar 2019, 02:11 last edited by Dariusz
    #1

    Hey

    I'm lost :- ), I started with QAbstractItemModel and QTreeView, subclassed what I needed, when I drop item on another item the expand signal does not appear. I have to expand all/hide all to force it to update the icon drawing...

    I call beginInsertRows()/end as well as Q_EMIT(itemFirst.index(),itemLast.index()) when finishing dropMimeData to notify views of data change but I still have no ">" when I finish the drop...

    What should I do ?

    Edit it seems that even if I add items to invisibleRoot they don't display either until I force refresh somehow...

    Regards
    Dariusz
    TIA

    R 1 Reply Last reply 17 Mar 2019, 09:16
    0
    • D Dariusz
      17 Mar 2019, 02:11

      Hey

      I'm lost :- ), I started with QAbstractItemModel and QTreeView, subclassed what I needed, when I drop item on another item the expand signal does not appear. I have to expand all/hide all to force it to update the icon drawing...

      I call beginInsertRows()/end as well as Q_EMIT(itemFirst.index(),itemLast.index()) when finishing dropMimeData to notify views of data change but I still have no ">" when I finish the drop...

      What should I do ?

      Edit it seems that even if I add items to invisibleRoot they don't display either until I force refresh somehow...

      Regards
      Dariusz
      TIA

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 17 Mar 2019, 09:16 last edited by
      #2

      @Dariusz said in QTreeView/Model drop action - no expand sign ?:

      call beginInsertRows()/end as well as Q_EMIT(itemFirst.index(),itemLast.index()) when finishing dropMimeData to notify views of data change but I still have no ">" when I finish the drop...
      What should I do ?

      to the expand icon appear either QAbstractItemModel::canFetchMore() returns true or QAbstractItemModel::rowCount() a value bigger 0 for the parent index.
      Also did you emit the dataChanged() signal on the parent index?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      2
      • D Offline
        D Offline
        Dariusz
        wrote on 17 Mar 2019, 09:46 last edited by
        #3

        @raven-worx said in QTreeView/Model drop action - no expand sign ?:

        Also did you emit the dataChanged() signal on the parent index?

        I've just read the post. I forgot to correct it. This is what I edit:

        bool testModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) {
             ...
             Q_EMIT dataChanged(itemFirst.index(),itemLast.index()) 
        }
        

        Hmmmm so I tried this, the parent is the object that is in function above.

            Q_EMIT dataChanged(parent, parent)
        

        Now this now "magically" works, I get extra ">" when I drop item on another item...
        I also learned that I also need to call Q_EMIT layoutChanged({parent}/flag) to update view if I drop items on expanded parent...

        Ok all good then, thanks! Weird issue o.o

        1 Reply Last reply
        0

        3/3

        17 Mar 2019, 09:46

        • Login

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