Partial text selection in QTreeView
-
I'm having difficulty allowing the user to select parts of the text in a QTreeView, and not have the selection confined to a single index. The default behavior of these item views is to select whole indexes.
I've tried to use a custom delegate with a QLabel as a persistent editor, which works well for individual indexes. Unfortunately I haven't been able to make selections work across multiple indexes.
This has been discussed before, but I couldn't find a clear solution.
Qt 4.8 on ancient hardware
-
@Giert
QTreeView
has a selectionBehaviour and a selectionMode. What do you mean byselect parts of the text in a QTreeView, and not have the selection confined to a single index. The default behavior of these item views is to select whole indexes.
?
-
@JonB I want the user to be able to select the text itself, rather than the whole index. The goal is both selection of only parts of a longer text, and to be able to select parts of several indexes at once.
Kind of like any text editor or browser.
-
Hi and welcome to devnet,
@Giert said in Partial text selection in QTreeView:
This has been discussed before, but I couldn't find a clear solution.
Can you link to these discussions ?
-
I was thinking of using a QLabel when I see this topic title, but apparently the OP has already done that.
I don't think there's more can be done.
AFAIK, you cannot select texts across multiple labels / widgets. They are not like elements in a webpage.
Once I was implementing a chat view, and my conclusion was, if I want to be able to select texts across multiple chat records, I cannot use item views, but html content based widgets, like QTextEdit / QWebView.