[SOLVED] Howto make a warning sign blinking
I would like to make a warning sign blinking on my GUI if the user presses a start button. Signal and slots I do already know well so I could take the event from the button.
But how I could make a warning sign blinking? Can you tell me what should I study (custom widgets, graphics view, ...)?
I would also be intrested for tutorials to this subject?
Where do you need that warning? Should the button blink, should a label or picture blink??
It sounds to me you need to inherit from the widget you need blinking and then setup a QTimer in that class that will be started when the button is pressed (event). Then in the timer event change the colour or any other option you need blinking.
It's a picture that should blink:
a possible way is to subclass QGraphicsPixmapItem and animate the opacity property.
class AnimatedGraphicsItem : public QObject, public QGraphicsPixmapItem
Q_PROPERTY(double opacity READ opacity WRITE setOpacity)
AnimatedGraphicsItem(QObject *parent = 0);
m_MyAnimatedGraphicsItem = new AnimatedGraphicsItem();
QGraphicsScene *m_scene = new QGraphicsScene();
QPixmap p; p.load(QString::fromStdString("SomeImage")); m_MyAnimatedGraphicsItem->setPixmap(p); m_scene.addItem(m_MyAnimatedGraphicsItem);
m_statusAni = new QPropertyAnimation(m_MyAnimatedGraphicsItem,"opacity");
Hope that helps
Another way would be to just make the "blinking" animation in a .gif. This gives you the most freedom as to what the blinking looks like.
Then all you'd need to do to show it is:
auto movie = new QMovie("path/to/animation/file.gif");
auto label = new QLabel();
Or inherit from QLabel and in a timerEvent change the border picture?? Then generate two pictures, warning on/off and change between them. The other options are more fancy must say!!
Thanks all for your suggestions.
After trying to implement the suggestion from sw0ce. I finaly realized the suggestion from Jeroentje@ho..