Simple QGraphicsTextItem animation (pos or blurRadius) is not smooth.
-
Hello,
I'm am trying out a simple text animation using theQGraphicsView
framework, using the code shown below to scroll the text vertically in and back out of the view.
However, the movement e.g. with the linear easing curve is not fluid as there seem to be transition discontinuities at certain times.How can I prevent this?
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QGraphicsScene* scene; scene = new QGraphicsScene(this); scene->setSceneRect(ui->graphicsView->rect()); ui->graphicsView->setScene(scene); //ui->graphicsView->setRenderHint(QPainter::Antialiasing, true); m_text = scene->addText("Hello World", QFont("Arial", 20)); m_text->setScale(4.0); qreal h = m_text->boundingRect().height()*m_text->scale(); m_text->setPos(0, -h); m_anim = new QPropertyAnimation(m_text, "y" , this); m_anim->setDuration(2000); m_anim->setStartValue(-h); m_anim->setEndValue(ui->graphicsView->height()); m_anim->setEasingCurve(QEasingCurve::Linear); } void MainWindow::on_pushButton_clicked() { m_anim->start(); }
-
With a blur graphics effect, the result is even worse. When animating the
blurRadius
property from 100 to 0, the last part of the animation is completely unstable, as the gif animation below shows
(the higher frame-rate GIF is too big to upload here, but shows the effect as even worse). -
My first approach would be to dump the values set during the property animation.
Any reason you commented the line that enables antialiasing? That could at least explain part of the text movement being irregular. -
@Asperamanca said in Simple QGraphicsTextItem animation (pos or blurRadius) is not smooth.:
Any reason you commented the line that enables antialiasing
Hey, thanks for your reply. I commented that one as a test. I tried both with antialiasing enabled and disabled.
-
I've tested your example and dumped the property animation output. The numbers really are irregular, although I do not know whether this sufficiently explains the visible effect. It may also be related to this bug report: https://bugreports.qt.io/browse/QTBUG-4416
Absolute value Relative to previous value -204 -202,245 -1,755 -200,373 -1,872 -198,501 -1,872 -196,629 -1,872 -194,757 -1,872 -192,885 -1,872 -191,013 -1,872 -189,141 -1,872 -187,269 -1,872 -185,397 -1,872 -183,525 -1,872 -181,653 -1,872 -179,781 -1,872 -177,909 -1,872 -176,037 -1,872 -174,165 -1,872 -172,293 -1,872 -170,304 -1,989 -168,549 -1,755 -166,677 -1,872 -164,805 -1,872 -162,933 -1,872 -161,061 -1,872 -159,189 -1,872 -157,317 -1,872 -155,328 -1,989 -153,573 -1,755 -151,701 -1,872 -149,829 -1,872 -147,957 -1,872 -146,085 -1,872 -144,213 -1,872 -142,341 -1,872 -140,469 -1,872 -138,48 -1,989 -136,725 -1,755 -134,853 -1,872 -132,981 -1,872 -131,109 -1,872 -129,237 -1,872 -127,365 -1,872 -125,493 -1,872 -123,621 -1,872 -121,749 -1,872 -119,877 -1,872 -118,005 -1,872 -116,133 -1,872 -114,261 -1,872 -112,389 -1,872 -110,517 -1,872 -108,645 -1,872 -106,773 -1,872 -104,901 -1,872 -103,029 -1,872 -101,157 -1,872 -99,168 -1,989 -97,413 -1,755 -95,541 -1,872 -93,669 -1,872 -91,797 -1,872 -89,925 -1,872 -88,053 -1,872 -86,181 -1,872 -84,309 -1,872 -82,437 -1,872 -80,565 -1,872 -78,576 -1,989 -76,821 -1,755 -74,832 -1,989 -73,077 -1,755 -71,088 -1,989 -69,333 -1,755 -67,461 -1,872 -65,589 -1,872 -63,717 -1,872 -61,845 -1,872 -59,973 -1,872 -58,101 -1,872 -56,229 -1,872 -54,357 -1,872 -52,485 -1,872 -50,613 -1,872 -48,741 -1,872 -46,869 -1,872 -44,997 -1,872 -43,125 -1,872 -41,253 -1,872 -39,381 -1,872 -37,509 -1,872 -35,637 -1,872 -33,765 -1,872 -31,776 -1,989 -30,021 -1,755 -28,149 -1,872 -26,16 -1,989 -24,288 -1,872 -22,533 -1,755 -20,661 -1,872 -18,789 -1,872 -16,917 -1,872 -15,045 -1,872 -13,173 -1,872 -11,301 -1,872 -9,429 -1,872 -7,557 -1,872 -5,685 -1,872 -3,813 -1,872 -1,941 -1,872 -0,069 -1,872 1,803 -1,872 3,675 -1,872 5,547 -1,872 7,419 -1,872 9,291 -1,872 11,163 -1,872 13,035 -1,872 15,024 -1,989 16,779 -1,755 18,651 -1,872 20,523 -1,872 22,512 -1,989 24,267 -1,755 26,139 -1,872 28,011 -1,872 29,883 -1,872 30 -0,117
-
@Asperamanca
Thanks for taking the time to try my example and investigate it, and sorry for not reacting sooner. I have completed my simple scrolling text widget which fades in and out using a transparency gradient, and although not perfectly smooth, I didn't have the time to investigate the issue further, but I'll post any findings that I may find later here. Cheers~