0

at the moment I am "playing" with C++ QT and Stylesheets. Normally I found everything in the documenttion, but unfortunatly the following problem not:

ExamplePic

In the example Picture you'll see my edited QPushButtons, QChecksBoxes and QRadioButtons. If they have the "focus", they get a "blue rectangle". And this is my Question: How can I edit this rectangle? Because I want to have it red. (or even not present) I tried with "*:focus" but this is not working. Also "QPalette::Highlight" is not the right thing.

Thanks in Advance BR THW

ThW
  • 11
  • 1
  • Can you show us a stylesheet code? – Shtol Krakov May 13 '16 at 11:56
  • Try with `border : none` or check the element `PE_FrameFocusRect` in QStyle.h – IAmInPLS May 13 '16 at 11:57
  • Of course, here is the code of the QPushbutton: `QPushButton:enabled, QToolButton:enabled { border: 1px solid #8f8f91; border-radius: 6px; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #000000, stop: 1 #111111); }` – ThW May 13 '16 at 11:59
  • `QPushButton:focus{ border : none; }` is not working. How can I use `PE_FrameFocusRect`. So you have an example? – ThW May 13 '16 at 12:03
  • If you want to use `PE_FrameFocusRect` : see [here](http://doc.qt.io/qt-5/qstylepainter.html#drawPrimitive) – IAmInPLS May 13 '16 at 12:14
  • @`PE_FrameFocusRect` - If I understand correctly, this is not like a Stylesheet (CSS) in QT, isn't it? Normally I have to override the paintEvent() function to use "DrawPrimitive", or is there any "global" and easy solution like the Stylesheet? – ThW May 13 '16 at 12:23
  • Well if it's a system selection (it's seems to be) by key focus you want to not present use `outline: 0`. If change color - `outline-color: `. From CSS syntax: `outline: outline-color || outline-style || outline-width | inherit` – Shtol Krakov May 13 '16 at 12:24
  • I think it would be helpful if you showed us your current Stylesheet code for the UI in the screen shot. When you say focus do you mean edit focus or when the mouse is over it? For QPushButton you might want to try customising :hover and :default – Robert Di Paolo May 13 '16 at 12:26
  • Yes, `outline` is what I am searching for..... now I have to play. Thanks! – ThW May 13 '16 at 12:31

0 Answers0