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. Bold QStringlist
Qt 6.11 is out! See what's new in the release blog

Bold QStringlist

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 908 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.
  • B Offline
    B Offline
    Buller
    wrote on last edited by
    #1

    What is the preferred way to create a bold QStringlist?

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      Qstringlist doesn't care about attributes like bold. That is the responsbility of how you render the string in in a widget. I "think" that if you add markup to the string such as QWidget::SetText("<b>bold text</b>") it would have the desired effect when rendered.

      The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

      1 Reply Last reply
      4
      • B Offline
        B Offline
        Buller
        wrote on last edited by
        #3

        I have a QTableWidget and when I call setHorizontalHeaderLabels(head), where head is a QStringList, I want the header text to be set to bold. But using QStringList is probably not a good approach?

        JonBJ 1 Reply Last reply
        0
        • B Buller

          I have a QTableWidget and when I call setHorizontalHeaderLabels(head), where head is a QStringList, I want the header text to be set to bold. But using QStringList is probably not a good approach?

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

          @Buller
          This has nothing to do with you setting the the labels from a QStringList.

          There are various ways of achieving the bolding. You access the header labels via QTableWidget::horizontalHeader(). Then you could either

          QFont font = tableWidget->horizontalHeader()->font();
          font.setBold(true);
          tableWidget->horizontalHeader()->setFont(font);
          

          or

          tableWidget->horizontalHeader()->setStyleSheet("QHeaderView { font-weight: bold; }")
          

          There are also ways of accessing individual header columns if you want that.

          1 Reply Last reply
          4
          • B Offline
            B Offline
            Buller
            wrote on last edited by
            #5

            The stylesheet option works fine. Thanks.

            aha_1980A 1 Reply Last reply
            2
            • B Buller

              The stylesheet option works fine. Thanks.

              aha_1980A Offline
              aha_1980A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi @Buller,

              thanks for the feedback. So please mark this topic as SOLVED now. Thanks!

              Qt has to stay free or it will die.

              1 Reply Last reply
              1

              • Login

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