View Full Version : Display QTreeView expanded in QDialog

21st December 2010, 01:39
I have a QTreeView in a QDialog that displays a hierarchical view of a text report. I want it to display fully expanded .. but it is always initially fully collapsed. There is a combo box in the QDialog that lets the user change the expand level after the report is displayed. The combo box index changed signal is connected to a slot that uses expandAll() and collapseAll() and some custom code to expand other levels if selected. It works fine... after the report is displayed. I have tried sending expandAll() directly after loading the data, in the showEvent of the QDialog, in the loading function for the data.. all the functions execute when I think they should... but the tree is collapsed when it is displayed initially. Any suggestions of more things to try?

21st December 2010, 07:53
No, no other suggestion. You call it at the wrong place. At least that is what my crystal ball says. Some code would be helpful. Is the model set up and attached to the view when you call expandAll()?

21st December 2010, 16:04
Yes, that was my 'crystal ball' idea, too. The model is setup and attached to the view - I tried that by using the Show event of the Dialog to expand rows...has to be populated by then I should think. I will try some other things and post if I can find a solution.

21st December 2010, 21:32
Yes, that was the problem. Dialogs load their data after exec if FetchMore is used. Needed to do the expand in a separate function as the data was being added to the model. Thanks for pointing me in the correct direction!