Important: Please read the Qt Code of Conduct -

QQuickPaintedItem paint() report error that QObject::killTimer: Timers cannot be stopped from another thread kernel\qobject.cpp

  • My code is as follows:

    void DrpltGyslPanel::paint(QPainter *painter)
        view_->render(painter, boundingRect(), view_->viewport()->rect(), Qt::KeepAspectRatio);

    DrpltGyslPanel is subclass of QQuickPaintedItem, view_ is instance of QGraphicsView .And I know DrpltGyslPanel::paint is called in QSGRenderThread, but what is this Timer used for?
    And this also caused child threads endless loop.
    How can I kill timer exactly? Or one more step for what exactly caused child threads endless loop?

  • QGraphicsView::addItem will start a timer by default interval(2000ms) at here.QGraphicsView::render will kill timer at here.When killing timer will estimate whether the current thread is thread timer lives to make sure timer usage is in the same thread.So we can not invoke QGraphicsView::render in DrpltGyslPanel::paint from QSGRenderThread.
    The code is corrected as follows:

    void DrpltGyslPanel::update(const QRect &rect)
        renderPixman = QPixmap(view_->viewport()->rect().size());//renderPixman is member variable
        QPainter painter(&renderPixman);
        view_->render(&painter, boundingRect(), view_->viewport()->rect(), 

    And why which will caused child threads endless loop, that is timerEvent alaways triggered.

Log in to reply