You can set a property to your QLabel
(or whatever widget you are using) and change the value of that property. Then you use that property in your stylesheets.
Example:
this->setStyleSheet("*[myproperty=\"true\"] { background-color: red }");
d_label = new QLabel("dynamic label", this);
d_label->setProperty("myproperty", false);
Then in your mousePressEvent you set and in mouseReleaseEvent you unset that property:
d_label->setProperty("myproperty", true); // or false when you wish to unset it
style()->unpolish(d_label);
style()->polish(d_label); // force a stylesheet recomputation