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. How can I get QTableWidget to work with rich text, word wrapping and resizing rows to contents correctly?
Forum Updated to NodeBB v4.3 + New Features

How can I get QTableWidget to work with rich text, word wrapping and resizing rows to contents correctly?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.9k 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.
  • B Offline
    B Offline
    Bastian
    wrote on last edited by
    #1

    Hi,

    I'm using a QTableWidget and when I add QTableWidgetItems into it, it works with word wrapping and resizing rows to contents, but the items don't support rich text.

    I thought the solution to that would be to use a QLabel as the cell's widget. While this does provide rich text support and word wrapping, resizeRowsToContents() doesn't seem to work correctly any more. Resizing the window containing the table and then calling resizeRowsToContents() can easily get the table into a situation where the QLabels haven't been sized large enough to display the entire text assigned to them.

    Is there a way to get this to work?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Following this thread, QTextDocument is the way to go.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      B 1 Reply Last reply
      2
      • SGaistS SGaist

        Hi and welcome to devnet,

        Following this thread, QTextDocument is the way to go.

        B Offline
        B Offline
        Bastian
        wrote on last edited by
        #3

        @SGaist Thanks a lot, that seems to have fixed the issue.

        1 Reply Last reply
        2

        • Login

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