QSS + style code
Hellow, i have some problem:
I have this code:
@ QPalette * p = new QPalette;
@QWidget[isColorRectangle = "true"]
border: 2px solid #C4C4C3;
Both the code work alone, but when they are together to work only QSS, proposal to make all the QSS does not fit
But if i declare a widget in designer all worke as it should
Advance many thanks for your help!
The documentation for "setPalette":http://doc.qt.nokia.com/latest/qwidget.html#palette-prop states that it should not be used together with stylesheets. You need to choose between setting the palette or using the stylesheet.
Yes, but if the widget is done in the designer, then everything works correctly
Then, how i can set color of the border around the widget when it is under the cursor without QSS
When not using stylesheets, you can reimplement "event()":http://doc.qt.nokia.com/latest/qwidget.html#event for the widget and listen for "QEvent::HoverEnter ":http://doc.qt.nokia.com/latest/qevent.html#Type-enum and QEvent::HoverLeave events. When you get a QEvent::HoverEnter you can set a bool variable to true and when you get a QHoverLeave you can set the bool variable to false and make sure to call "update()":http://doc.qt.nokia.com/atest/qwidget.html#update or "repaint":http://doc.qt.nokia.com/latest/qwidget.html#repaint after having changed the value of the variable
Then you can reimplement "paintEvent()":http://doc.qt.nokia.com/latest/qwidget.html#paintEvent for the widget to draw a border if the bool variable is set to true.
Does this approach work for you?