PDA

View Full Version : Using CSS with Static QTooltip?



droneone
26th December 2012, 16:18
Hi all, a question here regarding the manual triggering of a QToolTip using the static method QToolTip::showText().

When I use the following CSS, all tooltips that occur of their own volition (mousing over a button, etc.) are styled, but any tooltips drawn using QToolTip::showText() (i.e. throwing up a tooltip where the user clicks on a certain point in a widget) use the native color scheme. Is it possible to apply CSS to this use of tooltips?



QToolTip {
background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(99, 165, 209, 255), stop:1 rgba(64, 141, 196, 255));
color: rgb(255,255,255);
opacity:150;
text-align: center;
}


And, I'm triggering the tooltip manually by intercepting mousePressEvent in my widget, and then triggering a timer that ultimately calls a slot which does:



QPoint point = this->mapToGlobal(QPoint(m_curX, m_curY));
QString descText = "...";
QToolTip::showText(point, descText);


This is the only tooltip that isn't styled when the CSS is used in the mainwindow.ui file. Any advise would be highly appreciated. Thanks!