Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. Using QWebEngineView seems to disrupt QPropertyAnimation smoothness, even if QWebEngineView has just been destroyed

Using QWebEngineView seems to disrupt QPropertyAnimation smoothness, even if QWebEngineView has just been destroyed

Scheduled Pinned Locked Moved Unsolved QtWebEngine
qwebengineviewqpropertyanimat
1 Posts 1 Posters 494 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.
  • I Offline
    I Offline
    Ienfield
    wrote on 31 Aug 2021, 07:53 last edited by Ienfield
    #1

    I have a problem with QPropertyAnimation when QWebEngineView is used in the same QMainWindow.

    If I create 15 QPropertyAnimation (animate QGraphicsRectItem),
    and in the same time I use a QWebEngineView, then animations become very slow.

    I have created a demo (to compile yourself), with minimum usefull source code : https://media.nperf.com/files/misc/src_sandbox_web_animation.zip

    Tests made with one QMainWindow :

    After creating QWebEngineView, if I kill it, the problem continues.

    If I use QTimer loop instead of QPropertyAnimation, the problem is the same.

    Tests made with two QMainWindow :

    If I embed the QWebEngineView in an external window (new QMainWindow), then animations become smooth again.
    This new QMainWindow is not the same QMainWindow where QPropertyAnimations are running.

    However, this is not an acceptable solution for me, but this shows that there is a resource that is shared between QWebEngineView and QPropertyAnimations,
    if and only if the QWebEngineView was created in the same QMainWindow.

    So I wonder :

    • Did I kill the QWebEngineView correctly ?
    • Is there a way to seperate QWebEngineView threads from QMainWindow ?
    • Or any other solution...

    Environment context :

    This problem exist with two environments, win10/Qt5.15.2 and Mac/Qt5.15.0.

    But does not exist with ubuntu20/Qt5.12 and ubuntu18/Qt5.9.2.

    Reproductible code example (Code description of demo shared):

    1. The QPropertyAnimation change size of a QGraphicsRectItem :
    class AnimationBarItem : public QObject, public QGraphicsRectItem
    {
        Q_OBJECT
        Q_PROPERTY(QRectF rect READ rect WRITE setRect)
        ...
    }
    class AnimationBar : public QGraphicsView
    {
        Q_OBJECT
        ...
        AnimationBarItem *bar = nullptr;
    }
        
    void AnimationBar::setPourcent(qreal pourc){
      QPropertyAnimation *animation = new QPropertyAnimation(bar, "rect");
      animation->setDuration(200);
      animation->setStartValue(QRect(0, 0, 0, mH));
      animation->setEndValue(QRect(0, 0, ww,mH));
      animation->start();    
    }
    
    1. The QWebEngineView is created as follow :
    mWebEngineView = new QWebEngineView();//can't link to this, for compatibility with my project
    mWebEnginePage = new QWebEnginePage(mWebEngineView);
    mWebEnginePage->setView(mWebEngineView);
    mWebEngineView->setUrl(QUrl("http://www.google.com"));
    
    1. then add in QMainWindow with method :
    mLayoutForBrowse=new QVBoxLayout(ui->ZONE_webview);
    mLayoutForBrowse->addWidget(mWebEngineView);
    
    1. Or, in a new QMainWindow :
      <br>And not in the same QMainWindow like previous point, with :
    this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
    
    1. killing webview :
    void MainWindow::killWebView(bool is){
        if (mWebEngineView!=nullptr) mWebEngineView->stop();
        mWebEngineView->deleteLater();
        mLayoutForBrowse->deleteLater();
        mWebEnginePage->deleteLater();
        mWebEngineView=nullptr;
        mLayoutForBrowse=nullptr;
        mWebEnginePage=nullptr;
    }
    
    1 Reply Last reply
    0

    1/1

    31 Aug 2021, 07:53

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved