Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Howto make a warning sign blinking
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Howto make a warning sign blinking

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 7.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Snowseeker
    wrote on last edited by
    #1

    Hi,

    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?

    Thanks

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      Hi,
      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.

      Greetz, Jeroen

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Snowseeker
        wrote on last edited by
        #3

        It's a picture that should blink:
        !https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQ-0spNMNPd9m4_xPMjtDLI5UzyyD2pEXXqgeUG8bI__4DuqvA-zg!

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sw0ce
          wrote on last edited by
          #4

          Hi,

          a possible way is to subclass QGraphicsPixmapItem and animate the opacity property.

          @
          class AnimatedGraphicsItem : public QObject, public QGraphicsPixmapItem
          {
          Q_OBJECT
          Q_PROPERTY(double opacity READ opacity WRITE setOpacity)

          public:
          AnimatedGraphicsItem(QObject *parent = 0);

              .....
          

          };

          void SomeClass::InitGraphicsItem()
          {
          m_MyAnimatedGraphicsItem = new AnimatedGraphicsItem();
          QGraphicsScene *m_scene = new QGraphicsScene();
          MyGraphicsView.setScene(m_scene);

           QPixmap p;
           p.load(QString::fromStdString("SomeImage"));
          
          m_MyAnimatedGraphicsItem->setPixmap(p);
          
          m_scene.addItem(m_MyAnimatedGraphicsItem);
          

          }

          void SomeClass::DoBlink()
          {
          m_statusAni = new QPropertyAnimation(m_MyAnimatedGraphicsItem,"opacity");
          m_statusAni->setDuration(1600);
          m_statusAni->setStartValue(0.0);
          m_statusAni->setKeyValueAt(0.5,1.0);
          m_statusAni->setEndValue(0.0);
          m_statusAni->setEasingCurve(QEasingCurve::InCurve);
          m_statusAni->setLoopCount(-1);
          m_statusAni->start(QPropertyAnimation::DeleteWhenStopped)
          }
          @

          Hope that helps

          1 Reply Last reply
          0
          • Chris KawaC Offline
            Chris KawaC Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by
            #5

            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();

            label->setMovie(movie);
            movie->start();
            @

            1 Reply Last reply
            0
            • JeroentjehomeJ Offline
              JeroentjehomeJ Offline
              Jeroentjehome
              wrote on last edited by
              #6

              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!!

              Greetz, Jeroen

              1 Reply Last reply
              0
              • S Offline
                S Offline
                Snowseeker
                wrote on last edited by
                #7

                Thanks all for your suggestions.

                After trying to implement the suggestion from sw0ce. I finaly realized the suggestion from Jeroentje@ho..

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved