Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Display current item in bold font, NOT as selected w/ blue background
Qt 6.12 LTS is out! See what's new in the release blog

Display current item in bold font, NOT as selected w/ blue background

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 1.7k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I am subclassing QAbstractListModel for read-only display in a QListView and re-implementing the data() function. My list should display the items in normal font, but the selected item (or current item, since only one selection is allowed) should be in bold font. There should be no blue background, just white background with black text, but bold if it is the current item.

    So, how do I do this:

    (a) Avoid the default selection display for the current item as white text on a blue background;
    (b) Return the appropriate font, but in bold, in my model's data() function.

    Or is this the wrong way to do it? Do I also need to subclass QListView, for example, and override something there?

    Thanks!

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

      Hi,

      a-b) If you don't want any selection rectangle then you'll have to do it with a QStyledItemDelegate. However note that you are starting to go in the "against the design guidelines" territory.
      Since you want to change the font based on the selection, do it also in the QStyledItemDelegate.

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

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Thanks ... I'll probably reconsider in light of the "design guidelines" thing. But it's nice to know that it's possible, and how to do it.

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

          You're welcome !

          It's generally a good idea to follow the guidelines for a given platform :)

          Happy coding !

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

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            Samuel, congratulations on becoming the first "Qt Champion"! That's awesome!!

            Read about it here:
            "Qt Blog about Samuel Gaist":http://blog.qt.digia.com/blog/2014/10/20/say-hello-to-the-first-qt-champion/?utm_source=rss&utm_medium=rss&utm_campaign=say-hello-to-the-first-qt-champion

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

              Thank you very much :)

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

              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
              • Unsolved