Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Blinking a line in qt Painter



  • Managed to draw an arrow with paintEvent.
    Now i need to make it blink. Like to get some pointer.

    void MainWindow:: paintEvent(QPaintEvent *event)
    {

          QPen framepen(Qt::blue);
          framepen.setWidth(15);
          painter.setPen(framepen);
        if (state_){
          painter.drawLine(1400,160,1450,210);
          painter.drawLine(1400,260,1450,210);
         } else
       {                //how to make the line disappear?
        }
    

    }

    class MainWindow :public QMainWindow
    {
    bool state_;
    QTimer* timer;

    }


  • Lifetime Qt Champion

    Hi,

    One technique would be to clear your widget before doing any painting so you would only paint the arrow when you want it, otherwise you could repaint with the same color as the background.

    Hope it helps


Log in to reply