0
votes

I fill my QTreeWidget out of a thread. Works well so far, but after he data is populated, all items are not expanded but they are available. All items I added I set ...setExpanded(true);

This cause at the end the problem, that treeCount() is 1.

I want to avoid to set in constructer expandAll and I also want to avoid to make an extra List to count the items.

If I start the fill method from common app thread as a simple function, everything I ...setExpanded(true); is expanded after populate.

I there a trick to avoid this problem?

1
It would be very useful to see a minimal reproducible example if possible, or at least the relevant code blocksWilliam Miller

1 Answers

1
votes

Never mangle with a QObject from a different thread. All GUI object operations need to be done in the same thread.

Use a signal/slot mechanism between your threads to communicate new items. Alternatively, set up a new Q*ItemModel in the extra thread and pass it once in a signal.