0

I am using a custom CSS for a Qt5 window, but there is an ugly horizontal line on the selected button that I would like to get rid of it, or customize it.

enter image description here

This is the CSS I'm using right now.

* {
background-color: black;
color: white;
font: 24px;
}

QPushButton:disabled {
background-color: rgb(67, 67, 67);
border-color: rgb(67, 67, 67);
}

QPushButton {
color: black;
background-color: yellow;

border-width: 1px;
border-color: yellow;
border-style: solid;
border-radius: 10px;
min-width: 3em;
min-height: 30px;
padding: 6px;
}

QPushButton:pressed {
background-color: rgb(255, 193, 0);
border-color: rgb(255, 193, 0);
}

QPushButton:hover {
border-color: rgb(255, 193, 0);
}

QPushButton:default {
background-color: rgb(255, 255, 255);
}
LtWorf
  • 7,286
  • 6
  • 31
  • 45
  • off topic but use `border: 1px solid yellow;` instead of spilting it up. To your question, not sure yet thats weird. – Darcey Mckelvey May 08 '15 at 16:58
  • 1
    How about something like disable your focus on your push button with setfocuspolicy(...) function ? – Martin May 08 '15 at 22:17
  • I tried that and it seems to work, but I also lose the capability of using the keyboard. Ideally it's just the ugly line that I don't want. They added it in some more recent release of Qt5. It wasn't there before. – LtWorf May 08 '15 at 23:13
  • 1
    http://stackoverflow.com/questions/17280056/qt-css-decoration-on-focus I am sure you find a solution there. – Greenflow May 08 '15 at 23:55
  • No, it's a thing that they added in Qt 5.4. It wasn't there in the previous versions, and the question is about Qt4 – LtWorf May 11 '15 at 15:36
  • I tried your sytlesheet on Windows 8.1 with Qt 5.4.1 but the mentioned line does not exist. I just created a new widget with some buttons and applied your stylesheet. What should I do to be able to reproduce that effect ? – p.i.g. May 11 '15 at 18:09
  • I use it on Linux and I tried it also on Android and the line was there. I don't know about Windows. – LtWorf May 12 '15 at 13:50
  • Tried your css (copy/paste): http://s15.postimg.org/716wigp6j/button.png No blue line. The faint rectangle in the middle button is focus marker. Linux (Debian Sid). Self compiled Qt 5.6 (developers branch). – Greenflow May 13 '15 at 10:48
  • Might depend on the Qt style used. Anyway also that rectangle is awful and I would like to get rid of it. – LtWorf May 15 '15 at 16:35
  • I'm using your css, but I don't get the same behaviour. What do you get if you add `text-decoration: underline;` in `QPushButton:pressed`? Two lines? (blue and black as the text color) – Tarod May 19 '15 at 08:13
  • http://i.imgur.com/XxM6m47.png – LtWorf May 19 '15 at 14:25

0 Answers0