Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QQuickPaintedItem paint() report error that QObject::killTimer: Timers cannot be stopped from another thread kernel\qobject.cpp
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 611 Views
  • 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.
  • Crawl.WC Offline
    Crawl.WC Offline
    Crawl.W
    wrote on last edited by Crawl.W
    #1

    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?

    1 Reply Last reply
    0
    • Crawl.WC Offline
      Crawl.WC Offline
      Crawl.W
      wrote on last edited by
      #2

      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(), 
          Qt::KeepAspectRatio);
      
          QQuickPaintedItem::update(rect);
      }
      

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

      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