Re: How to change border colors of a widget?
I want to change the color of right border of a widget and leave others unchanged. Is it possible? If so, How can I do that?
In the following code
Code:
#include <QtGui>
int main(int argc, char *argv[])
{
// line.setStyleSheet("border: 10px solid blue;"); //<----------- first
st.append("border-right: 10px solid blue;");
line.setStyleSheet(st); //<------------ second
st.append("border-top: 10px solid blue;");
// line.setStyleSheet(st); //<----------- third
st.append("border-left: 10px solid blue;");
st.append("border-bottom: 10px solid blue;");
// line.setStyleSheet(st); //<------------ forth
hl.addWidget(&line);
window.setLayout(&hl);
window.resize(640, 480);
window.show();
return app.exec();
}
the statements marked first and forth are working as expected, the third has some effects, but the second has no effect.
Added after 1 8 minutes:
Consider following paragraphs from Qt's Docs http://doc.qt.io/qt-4.8/stylesheet-reference.html:
Quote:
One to four occurrences of Brush, specifying the top, right, bottom, and left edges of a box, respectively. If the left color is not specified, it is taken to be the same as the right color. If the bottom color is not specified, it is taken to be the same as the top color. If the right color is not specified, it is taken to be the same as the top color. Example:
QLabel { border-color: red } /* red red red red */
QLabel { border-color: red blue } /* red blue red blue */
QLabel { border-color: red blue green } /* red blue green blue */
QLabel { border-color: red blue green yellow } /* red blue green yellow */
Quote:
border-color The color of all the border's edges. Equivalent to specifying border-top-color, border-right-color, border-bottom-color, and border-left-color.
Quote:
border-right Shorthand notation for setting the widget's right border. Equivalent to specifying border-right-color, border-right-style, and/or border-right-width.
There's similar statements for width and style.
Now, isn't this in contradiction to the what happens in the example of first post?