设置样式:
QLineEdit{
border:1px solid gray;
}
QLineEdit:hover{
border-width:2px;
border-color:rgb(170, 170, 255);
}
QLineEdit:focus {
border-width:2px;
border-color:rgb(170, 170, 255);
}
注意:QLineEdit:focus这是获取焦点的样式
还有一种方法,
class CEdit : public QLineEdit {
protected:
void focusInEvent(QEvent *);
void focusOutEvent(QEvent *);
};
重载上面两个函数,在这两个函数了,改变焦点的颜色