79626208

Date: 2025-05-17 05:16:26
Score: 1.5
Natty:
Report link

Ok - managed to work it out :-)

Each item on the screen has an attached stylesheet - so we can set the stylesheet of the item e.g.:

self.SongList.setStyleSheet("QListView::item:selected {background-color: #000088;}")

This sets the currently selected item to blue - see https://doc.qt.io/qt-6/stylesheet-examples.html

The trick is to use the "::item:" element...

In the preferences dialog in my app I can allow the user to select what colour they want:

color = QColorDialog.getColor()
# use color.name()   to get the #nnnnnn value

Many thanks for the suggestions, however, this allows me to give the user the ability to keep the theme, but then select what they want as a highlight colour.

I've got a few more tweaks and testing to do, but I'll put uploading the code to https://github.com/carlbeech/OpenSongViewer in a few days.

Thanks

Carl.

Reasons:
  • Blacklisted phrase (0.5): thanks
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Carl Beech