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. QTableWidgetItem while editing has smaller font

QTableWidgetItem while editing has smaller font

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 510 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.
  • P Offline
    P Offline
    Publicnamer
    wrote on last edited by Publicnamer
    #1

    When I double-click on a QTableWidgetItem in order to edit its text, the font that it uses is smaller than the font that is used after editing has ended.

    I'm using a QPlainTextEdit subclass for the editor. There is only one place where the "delegate" that creates the QPlainTextEdit editors is defined, so it is the same delegate for ALL cells.

    Why was it designed this way? If I need to create QPlainTextEdits that have different characteristics for different cells, it would require some crazy coding practices, like letting the delegate have access to my actual data (not the table model).

    Furthermore the delegate only knows about the "index", not the row/column. It's not clear how convert the index to a row/column.

    JonBJ 1 Reply Last reply
    0
    • P Publicnamer

      When I double-click on a QTableWidgetItem in order to edit its text, the font that it uses is smaller than the font that is used after editing has ended.

      I'm using a QPlainTextEdit subclass for the editor. There is only one place where the "delegate" that creates the QPlainTextEdit editors is defined, so it is the same delegate for ALL cells.

      Why was it designed this way? If I need to create QPlainTextEdits that have different characteristics for different cells, it would require some crazy coding practices, like letting the delegate have access to my actual data (not the table model).

      Furthermore the delegate only knows about the "index", not the row/column. It's not clear how convert the index to a row/column.

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

      @Publicnamer said in QTableWidgetItem while editing has smaller font:

      Furthermore the delegate only knows about the "index", not the row/column. It's not clear how convert the index to a row/column.

      Not an answer to your original question. But be aware the QModelIndex has members row() & column() for that, so you do know these wherever you have an index.

      P 1 Reply Last reply
      0
      • JonBJ JonB

        @Publicnamer said in QTableWidgetItem while editing has smaller font:

        Furthermore the delegate only knows about the "index", not the row/column. It's not clear how convert the index to a row/column.

        Not an answer to your original question. But be aware the QModelIndex has members row() & column() for that, so you do know these wherever you have an index.

        P Offline
        P Offline
        Publicnamer
        wrote on last edited by
        #3

        @JonB OK thanks.

        Setting the font for all QPlainTextEdit, I can achieve somewhat OK results.

        However the real problem with QPlainTextEdit is that it has internal padding such that if the original row needed to be 60 pixels high to accommodate the text, the QPlainTextEdit's row will need to be 65 or 70 pixels high.

        Is there a way to eliminate the internal padding of a QPlainTextEdit?

        M 1 Reply Last reply
        0
        • P Publicnamer

          @JonB OK thanks.

          Setting the font for all QPlainTextEdit, I can achieve somewhat OK results.

          However the real problem with QPlainTextEdit is that it has internal padding such that if the original row needed to be 60 pixels high to accommodate the text, the QPlainTextEdit's row will need to be 65 or 70 pixels high.

          Is there a way to eliminate the internal padding of a QPlainTextEdit?

          M Offline
          M Offline
          mpergand
          wrote on last edited by
          #4

          @Publicnamer
          You can set the document margin with:
          setDocumentMargin(qreal margin)
          (the default value is 4 i think)

          P 1 Reply Last reply
          0
          • M mpergand

            @Publicnamer
            You can set the document margin with:
            setDocumentMargin(qreal margin)
            (the default value is 4 i think)

            P Offline
            P Offline
            Publicnamer
            wrote on last edited by
            #5

            @mpergand What class has that method? I don't see it anywhere, not QPlainTextEdit, QTableWidget, nor QTableWidgetItem.

            JonBJ 1 Reply Last reply
            0
            • P Publicnamer

              @mpergand What class has that method? I don't see it anywhere, not QPlainTextEdit, QTableWidget, nor QTableWidgetItem.

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

              @Publicnamer
              QTextDocument::setDocumentMargin().

              QTextDocument *QPlainTextEdit::document() const lets you access the QTextDocument it is using.

              P 1 Reply Last reply
              0
              • JonBJ JonB

                @Publicnamer
                QTextDocument::setDocumentMargin().

                QTextDocument *QPlainTextEdit::document() const lets you access the QTextDocument it is using.

                P Offline
                P Offline
                Publicnamer
                wrote on last edited by
                #7

                @JonB Yep I found it. I'm now doing setDocumentMargin(0), which helps a little but there is still a margin of maybe 2 pixels at the top and bottom. Double clicking on a row results in the text shifting down a couple pixels and the vertical scrollbar appearing.

                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