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 4 Nov 2020, 11:45 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

    J 1 Reply Last reply 4 Nov 2020, 11:53
    0
    • G Giert
      4 Nov 2020, 11:45

      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

      J Online
      J Online
      JonB
      wrote on 4 Nov 2020, 11:53 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 4 Nov 2020, 12:23
      0
      • J JonB
        4 Nov 2020, 11:53

        @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 4 Nov 2020, 12:23 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
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 4 Nov 2020, 19:14 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 5 Nov 2020, 08:28
          1
          • B Offline
            B Offline
            Bonnie
            wrote on 5 Nov 2020, 02:43 last edited by Bonnie 11 May 2020, 03:03
            #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 5 Nov 2020, 08:16
            0
            • B Bonnie
              5 Nov 2020, 02:43

              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 5 Nov 2020, 08:16 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
              • S SGaist
                4 Nov 2020, 19:14

                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 5 Nov 2020, 08:28 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

                5/7

                5 Nov 2020, 02:43

                • Login

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