Nominate our 2022 Qt Champions!

How to create/edit slot to change a widget's color

  • I am trying to change some formatting in QT based on some values changing. I am using some epicsQT widgets which read some values off instruments (humidity is one example). I want the color of a button to change (and flash, if possible) to change if the value exceeds some limit (let's say 85 percent for humidity).

    Is there a signal/slot combination to use? I've tried the update() slot, and tried to model the painterEvent that's covered in the analogClock example. But I don't think what I want to do is an "event." Aren't events different than signals?

    For testing, I've been trying with just a simple spinBox, and a qanalogSlider to try to get the MainWindow to change color. I just want the color to change (and possibly flash) if the value goes over something arbitrary (say greater than 5).

    I think I understand how to basically add custom slots, if there's not one ready to do what I want, but I can't seem to get my little test to change any colors.

Log in to reply