How to make real time playback with QGraphicsView and repaint of QWidget?
Unsolved
General and Desktop
-
Hello everyone, in my application I have the ability to reproduce a graph of value changes and there was a problem with it.
one frame playback looks like:
QElapsedTimer timer; timer.start(); if (current_time_ >= end_time_) current_time_ = start_time_; OnSetTime(current_time_); qDebug() << timer.elapsed(); /* first cout */ cursor_time_label_->setText(QString::number(current_time_)); if (graphic_editor->isVisible()) /* QGraphicsView */ graphic_editor->SetCursorTime(current_time_); qDebug() << timer.elapsed(); /* second cout */ int elapsed(timer.elapsed()); if (elapsed < 4) elapsed = 4; current_time_ += elapsed * play_speed_factor_;
OnSetTime method
current_time_ = time; /******* loop of filling some slots ******************/ if (scheme_view_->isVisible()) /* QGraphicsView */ scheme_graphics_view_->repaint(); if (channel_widget_->isVisible()) /* QWidget with reimpl paintEvent */ channel_widget_->repaint();
graphic_editor->SetCursorTime(current_time_)
qreal pos = ms * background_item_->rect().width() / duration_; cursor_item_->setX(pos); repaint();
while "current time" not hits to graphic_editor the first output of QElapsedTimer returns on average 42, and secont 52,
but when the "current time" hits to graphic_editor, QElapsedTimer returns 7 and 16 respectively.
because of this, it seems that playback slows down when the current time hits the editor.is it possible to fix this error so that playback was at +- real time?
if i replace all calls repaint() to update() elapsed timer returns 0