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 531 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 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?

    Pl45m4P 1 Reply Last reply
    0
    • C clarify

      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?

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #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
      1
      • Pl45m4P Pl45m4

        @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 last edited by clarify
        #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 Pl45m4P 2 Replies Last reply
        0
        • C clarify

          @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 last edited by mpergand
          #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

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

            Pl45m4P Offline
            Pl45m4P Offline
            Pl45m4
            wrote on last edited by Pl45m4
            #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
            0
            • Pl45m4P Pl45m4

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

              Pl45m4P 1 Reply Last reply
              1
              • M mpergand

                @Pl45m4 said in Currently selected table in QTextEdit?:

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

                Exists since Qt4 !

                Pl45m4P Offline
                Pl45m4P Offline
                Pl45m4
                wrote on 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

                • Login

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