yuriry
4th October 2008, 10:09
I have a slight problem displaying [+] signs in a standard tree view.
The view is connected to a custom tree model. The model is initially empty. When rowCount() for some tree node is called first time the model submits a request to a separate thread using a queued connection and returns 0. The thread in the meantime loads data from the database and sends a response back to the model, aslo using a queued connection. When the model processes the response on the GUI thread, it calls beginInsertRows(), inserts the node's children and calls endInsertRows(). But [+] sing does not show up under the corresponding node in the tree view. However, as soon as I change focus to another window the [+] sign appears at the right place.
Just wanted to ask if anyone has experienced similar problem? Is there a way make [+] sing appear right away?
PS: I verified that when endInsertRows() is called, rowCount() is also called before endInsertRows() returns, and this rowCount() call returns correct number of rows, namely, the number of records retrieved from the database.
PPS: I also move tree nodes around using drag/drop. Re-parenting also goes through the same path: tree view -> tree model -> thread -> database ->thread ->tree model -> tree view. When a response arrives to the tree model, the model removes the moved node from the old position and inserts it to a new position. And there is no problem displaying [+] signs by the tree view in this scenario, it only manifests itself when the model is initially populated.
The view is connected to a custom tree model. The model is initially empty. When rowCount() for some tree node is called first time the model submits a request to a separate thread using a queued connection and returns 0. The thread in the meantime loads data from the database and sends a response back to the model, aslo using a queued connection. When the model processes the response on the GUI thread, it calls beginInsertRows(), inserts the node's children and calls endInsertRows(). But [+] sing does not show up under the corresponding node in the tree view. However, as soon as I change focus to another window the [+] sign appears at the right place.
Just wanted to ask if anyone has experienced similar problem? Is there a way make [+] sing appear right away?
PS: I verified that when endInsertRows() is called, rowCount() is also called before endInsertRows() returns, and this rowCount() call returns correct number of rows, namely, the number of records retrieved from the database.
PPS: I also move tree nodes around using drag/drop. Re-parenting also goes through the same path: tree view -> tree model -> thread -> database ->thread ->tree model -> tree view. When a response arrives to the tree model, the model removes the moved node from the old position and inserts it to a new position. And there is no problem displaying [+] signs by the tree view in this scenario, it only manifests itself when the model is initially populated.