Widget in place of an icon in QTreeView?
-
I want to display a small widget instead of an icon in QTreeView, can this be done?
-
Hi,
I'd say: probably yes. But it might be hurting performances. What should that widget do ?
-
It's sort of an indefinite progress indicator to indicate that a lengthy operation is running on this list item. There can be at most one such indicator, so performance shouldn't be an issue.
I could implement it by switching the icon on timer but that's really ugly. -
Then why not put a progress bar over the cell where the operation is currently going on ?
-
Hmm, it didn't occur to me. Thanks for the idea. I guess with careful positioning I can overlay it just right. Not sure if I can get the coordinates I need from the tree view, though.
-
visualRect comes to mind for that
-
Now that I'm trying it out, it doesn't seem feasible. For instance, how am I going to handle scrolling the list while the progress bar is on screen.
Do you have any other idea on how to implement it? I'm thinking of callingsetIcon()
a couple times a second, will that be smooth enough? -
What about writing your own delegate ?
-
Does QTreeView work with delegates? I thought only widget does, but not the view. Thanks, I'll look into it.
-
Sure it does, the base delegate handling comes from QAbstractItemView