0

I have a custom widget comprised of a QFrame housing a QWebEngineView, which displays a <textarea/> in its HTML.

In the following picture, the top widget is a QComboBox, the middle widget is my custom widget, and the bottom widget is a QPushButton. What I want is to make my custom widget have, when selected, the glowing selection border that the QComboBox has.

My two requirements are:

  1. The border only shows when my custom widget is actually selected, not showing all the time.
  2. The style of the border (color, width, etc) should be the default style of whatever platform I'm running my app on. For example, I don't want macOS' blue selection border on Windows.

How do I go about doing this?

example picture

There is an existing question (How to add border around QWidget?), but the answer is a custom style rather than the platform default style, and doesn't explain how to make the border contingent upon selection instead of being displayed all the time.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
midrare
  • 2,371
  • 28
  • 48
  • The QComboBox does not exist that effect by default in other styles and platforms – eyllanesc Mar 05 '19 at 04:38
  • @eyllanesc I know the style differs from platform to platform, but that's what I want to do; I whatever the default style of the platform is, I want my selection border to use it. I want the selection border to be thin and black on Windows, and thick and blue on macOS. – midrare Mar 05 '19 at 04:43
  • What you point out is complicated since I think that this task is done by the private Qt API (D-Pointer / PIMPL), good luck since it uses the libraries of each OS. – eyllanesc Mar 05 '19 at 04:47
  • @sorbet You could probably do this by altering the stylesheet of the comboBox by using an `eventFilter` to target FocusIn/Out events. You can use `platform` or `os` to figure out which platform your app is running on. – Shilo Mar 11 '19 at 06:37

0 Answers0