當鼠標光標經過QLabel
時,我想將文本變爲綠色並加下劃線,但它只是變成綠色,並沒有下劃線。下劃線QLabel的文字「懸停」
QLabel:hover { color: green; text-decoration: underline;}
我在做什麼錯?
編輯: 固定,我使用:
void QClickableLabel::enterEvent (QEvent *event)
{
Q_UNUSED (event);
setStyleSheet ("QLabel { color: green; text-decoration: underline; }");
}
void QClickableLabel::leaveEvent (QEvent *event)
{
Q_UNUSED (event);
setStyleSheet ("QLabel { color: black; }");
}
您可以通過QSS定製做(看起來像標籤)'QToolButton':http://stackoverflow.com/questions/18250591/how-to-style-pushbuttons-image-size-on- hover-pressed -in-qt4-using-css/18251809#18251809 –
你需要'setMouseTracking(true);' –