Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Partial text selection in QTreeView
QtWS25 Last Chance

Partial text selection in QTreeView

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtreeviewqt4.8selection
7 Posts 4 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Giert
    wrote on last edited by
    #1

    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

    JonBJ 1 Reply Last reply
    0
    • G Giert

      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

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Giert
      QTreeView has a selectionBehaviour and a selectionMode. What do you mean by

      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.

      ?

      G 1 Reply Last reply
      0
      • JonBJ JonB

        @Giert
        QTreeView has a selectionBehaviour and a selectionMode. What do you mean by

        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.

        ?

        G Offline
        G Offline
        Giert
        wrote on last edited by
        #3

        @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.

        example

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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 ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          G 1 Reply Last reply
          1
          • B Offline
            B Offline
            Bonnie
            wrote on last edited by Bonnie
            #5

            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.

            G 1 Reply Last reply
            0
            • B Bonnie

              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.

              G Offline
              G Offline
              Giert
              wrote on last edited by
              #6

              @Bonnie that's really unfortunate. There is a lot of keyword highlighting in the application, and the current implementation, QPlainTextEdit, runs into serious performance issues, even with a lowered text block limit. Thanks anyway!

              1 Reply Last reply
              0
              • SGaistS SGaist

                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 ?

                G Offline
                G Offline
                Giert
                wrote on last edited by
                #7

                @SGaist of course!

                This OP gave up, as I'm about to do

                while this discussion gave me hope of handling mouse events in the view myself

                This discussion didn't really go anywhere at all

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved