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. How to make real time playback with QGraphicsView and repaint of QWidget?

How to make real time playback with QGraphicsView and repaint of QWidget?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 148 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.
  • D Offline
    D Offline
    Daniil S.
    wrote on last edited by Daniil S.
    #1

    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

    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