⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

Text selection in model-view implementation

  • Hi, I want to ask if is possible (and how if possible) to make QTreeView's item's text selectable by mouse like when:

    label = QLabel("Selectable text")

    I'm using customized QTreeView, QAbstractListModel and QStyledItemDelegate.
    Delegate is painting QTextDocument.

    Not sure if these information are enough.

    Can anyone help me please?

  • Banned

    I believe (if I am understanding what you mean by selectable) that the fields of a QTreeView are by default selectable and/or editable you would have to explicitly turn that off to stop them from being such.

  • I want to be able to do this kind of selection:

    • select text from item and be able to copy selection with shortcut. Like QLabel when you set interaction flag TextSelectableByMouse

  • I describe it incomprehensibly or it's not possible?

  • Banned

    It required to much research on my part to pursue in the format that it was given and it is not something that I need to do for anything I am working on.

    So you would either need to present it as an MRE (Minimal Reproducible Example) showing how the QLabel works and how that does not work in the QTreeView -- then I can look at that code and determine more easily what it is you are striving to do without having to spend a lot of my time discerning that just to answer your question. Aka you need to do the work to get your question answered not the other way around.

Log in to reply