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. Partially bold text in a QListWidgetItem
Forum Updated to NodeBB v4.3 + New Features

Partially bold text in a QListWidgetItem

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 7.1k Views 1 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.
  • W Offline
    W Offline
    wjlrkjjv
    wrote on last edited by
    #1

    Hello!

    I would like to know what's the best way to just have partially bold text (single bold words) in a QListWidgetItem.

    I tried with delegate, drawing normal text, then bold text, then normal text again... but had problems with positioning the blocks of text in sequence.
    I also tried with showing a QTextDocument per row, but this seems a bit of an overkill, I just need a bold word per row.

    It doesnt matter how the bold text is defined, could be "text<boldtext>text" or with html tags, nevermind. It should just work :)

    Thank you in advance!

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      There is no way that "just works". I once wrote a rich text delegate that basically used a QTextDocument per cell, and a later version even used webkit to render a cell (so it could support CSS to a much larger extend). Overkill? Perhaps, but at least it worked. I gave it up though, because I could not find a way to make the items properly styled as well. The way QStyledItemDelegate works with rendering is just not all that convenient.

      1 Reply Last reply
      0
      • W Offline
        W Offline
        wjlrkjjv
        wrote on last edited by
        #3

        I just tried with a QLabel with rich text for a row. Then I set the label as item widget: listWidget->setItemWidget
        Seems to "just work" :) But havent thoroughly tested it yet...

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          Putting widgets in there is even more expensive, and harder to manage. I used QTextDocument::drawContents(), and kept the textdocuments in a cache.

          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