Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Partial text selection in QTreeView

    General and Desktop
    qtreeview qt4.8 selection
    4
    7
    366
    Loading More Posts
    • 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
      Giert last edited by

      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

      JonB 1 Reply Last reply Reply Quote 0
      • JonB
        JonB @Giert last edited by

        @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 Reply Quote 0
        • G
          Giert @JonB last edited by

          @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 Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 1
            • B
              Bonnie last edited by 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 1 Reply Last reply Reply Quote 0
              • G
                Giert @Bonnie last edited by

                @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 Reply Quote 0
                • G
                  Giert @SGaist last edited by

                  @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 Reply Quote 0
                  • First post
                    Last post