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. Currently selected table in QTextEdit?
Forum Updated to NodeBB v4.3 + New Features

Currently selected table in QTextEdit?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 530 Views 2 Watching
  • 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.
  • C Offline
    C Offline
    clarify
    wrote on 12 May 2023, 21:36 last edited by
    #1

    I'm trying to figure out how I can get information
    about the currently selected table, row and/or cell
    in a QTextEdit.
    Is there such a capability?

    P 1 Reply Last reply 12 May 2023, 21:49
    0
    • C clarify
      12 May 2023, 21:36

      I'm trying to figure out how I can get information
      about the currently selected table, row and/or cell
      in a QTextEdit.
      Is there such a capability?

      P Offline
      P Offline
      Pl45m4
      wrote on 12 May 2023, 21:49 last edited by Pl45m4 5 Dec 2023, 21:59
      #2

      @clarify said in Currently selected table in QTextEdit?:

      row and/or cell in a QTextEdit

      That a QTextEdit has cells and rows/cols is new to me :)

      You are sure that you don't have a QTableView (or -Widget) or something else model-based?!

      Edit:
      Are you talking about HTML tables in QTextEdit?
      AFAIK QTextEdit::setHtml is one-way. You set CSS/HTML once and you see the result. You don't get any callbacks or something else than the QTextEdit signals and events back from it.


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      C 1 Reply Last reply 12 May 2023, 22:10
      1
      • P Pl45m4
        12 May 2023, 21:49

        @clarify said in Currently selected table in QTextEdit?:

        row and/or cell in a QTextEdit

        That a QTextEdit has cells and rows/cols is new to me :)

        You are sure that you don't have a QTableView (or -Widget) or something else model-based?!

        Edit:
        Are you talking about HTML tables in QTextEdit?
        AFAIK QTextEdit::setHtml is one-way. You set CSS/HTML once and you see the result. You don't get any callbacks or something else than the QTextEdit signals and events back from it.

        C Offline
        C Offline
        clarify
        wrote on 12 May 2023, 22:10 last edited by clarify 5 Dec 2023, 22:17
        #3

        @Pl45m4 said in Currently selected table in QTextEdit?:

        Are you talking about HTML tables in QTextEdit?

        Yes. You can try this yourself:

          textedit->setHtml("<html><body><table border=1><tr><td>1<td width=100>2<td>3<tr><td>4<th>5<th>6</table>");
        

        The QTextEdit is smart enough to parse the HTML for the table and display it nicely. However as yet I don't see how I can let the user edit the table's structure e.g. add rows, delete column etc.

        Does anyone know if that is coming in Qt 6? (My Linux distro is stuck at Qt 5).

        AFAIK QTextEdit::setHtml is one-way.

        You can read HTML out of the QTextEdit with a call to toHtml. And it's an editor, so you can edit anything in there. It's just the table structure that I can't see a way to alter.

        M P 2 Replies Last reply 12 May 2023, 22:37
        0
        • C clarify
          12 May 2023, 22:10

          @Pl45m4 said in Currently selected table in QTextEdit?:

          Are you talking about HTML tables in QTextEdit?

          Yes. You can try this yourself:

            textedit->setHtml("<html><body><table border=1><tr><td>1<td width=100>2<td>3<tr><td>4<th>5<th>6</table>");
          

          The QTextEdit is smart enough to parse the HTML for the table and display it nicely. However as yet I don't see how I can let the user edit the table's structure e.g. add rows, delete column etc.

          Does anyone know if that is coming in Qt 6? (My Linux distro is stuck at Qt 5).

          AFAIK QTextEdit::setHtml is one-way.

          You can read HTML out of the QTextEdit with a call to toHtml. And it's an editor, so you can edit anything in there. It's just the table structure that I can't see a way to alter.

          M Offline
          M Offline
          mpergand
          wrote on 12 May 2023, 22:37 last edited by mpergand 5 Dec 2023, 22:37
          #4

          @clarify
          Have a look at QTextTable

          The table currently being edited by the cursor is found with QTextCursor::currentTable(). This allows its format or dimensions to be changed after it has been inserted into a document.

          A table's size can be changed with resize(), or by using insertRows(), insertColumns(), removeRows(), or removeColumns(). Use cellAt() to retrieve table cells.

          1 Reply Last reply
          1
          • C clarify
            12 May 2023, 22:10

            @Pl45m4 said in Currently selected table in QTextEdit?:

            Are you talking about HTML tables in QTextEdit?

            Yes. You can try this yourself:

              textedit->setHtml("<html><body><table border=1><tr><td>1<td width=100>2<td>3<tr><td>4<th>5<th>6</table>");
            

            The QTextEdit is smart enough to parse the HTML for the table and display it nicely. However as yet I don't see how I can let the user edit the table's structure e.g. add rows, delete column etc.

            Does anyone know if that is coming in Qt 6? (My Linux distro is stuck at Qt 5).

            AFAIK QTextEdit::setHtml is one-way.

            You can read HTML out of the QTextEdit with a call to toHtml. And it's an editor, so you can edit anything in there. It's just the table structure that I can't see a way to alter.

            P Offline
            P Offline
            Pl45m4
            wrote on 12 May 2023, 22:44 last edited by Pl45m4 5 Dec 2023, 22:44
            #5

            @clarify said in Currently selected table in QTextEdit?:

            You can read HTML out of the QTextEdit with a call to toHtml. And it's an editor, so you can edit anything in there. It's just the table structure that I can't see a way to alter.

            I know that you can change the data in HTML tables but you dont have the functionality that a e.g.QTableView or QTableWidget provides. With hover events, interactive header, data model etc..

            Look at @mpergand 's answer.
            QTextTable (a class I didnt know of) was added in Qt6.


            If debugging is the process of removing software bugs, then programming must be the process of putting them in.

            ~E. W. Dijkstra

            M 1 Reply Last reply 12 May 2023, 22:59
            0
            • P Pl45m4
              12 May 2023, 22:44

              @clarify said in Currently selected table in QTextEdit?:

              You can read HTML out of the QTextEdit with a call to toHtml. And it's an editor, so you can edit anything in there. It's just the table structure that I can't see a way to alter.

              I know that you can change the data in HTML tables but you dont have the functionality that a e.g.QTableView or QTableWidget provides. With hover events, interactive header, data model etc..

              Look at @mpergand 's answer.
              QTextTable (a class I didnt know of) was added in Qt6.

              M Offline
              M Offline
              mpergand
              wrote on 12 May 2023, 22:59 last edited by
              #6

              @Pl45m4 said in Currently selected table in QTextEdit?:

              QTextTable (a class I didnt know of) was added in Qt6.

              Exists since Qt4 !

              P 1 Reply Last reply 13 May 2023, 12:19
              1
              • M mpergand
                12 May 2023, 22:59

                @Pl45m4 said in Currently selected table in QTextEdit?:

                QTextTable (a class I didnt know of) was added in Qt6.

                Exists since Qt4 !

                P Offline
                P Offline
                Pl45m4
                wrote on 13 May 2023, 12:19 last edited by
                #7

                @mpergand said in Currently selected table in QTextEdit?:

                Exists since Qt4 !

                Mh ok. There were only Qt6 Releases listed in the documentation, not even 5.15.
                Still never heard of it and it doesnt seem to be used very often.


                If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                ~E. W. Dijkstra

                1 Reply Last reply
                0

                6/7

                12 May 2023, 22:59

                • Login

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