Hi,
I have QCanvas, QCanvasView, QCanvasText objects. I implemented a scrolling text function which will be triggered by a QTimer to move QCanvasText object to left 2 pixels in every 100 ms.
How to avoid it flickering?
Thanks.
Hi,
I have QCanvas, QCanvasView, QCanvasText objects. I implemented a scrolling text function which will be triggered by a QTimer to move QCanvasText object to left 2 pixels in every 100 ms.
How to avoid it flickering?
Thanks.
Depends how you implemented it.
Here is a segment of my code:
m_canvasView = new QCanvasView(this);
m_canvas = new QCanvas();
m_canvasView->setCanvas(m_canvas);
m_canvasText = new QCanvasText(m_canvas);
m_canvasText->setText("whatever");
m_timer = new QTimer(this);
connect(m_timer, SIGNAL(timeout()), SLOT(myTick()));
m_timer->start(100);
myTick()
{
m_x -= 2;
m_canvasText->move(m_x, m_y);
}
Try using QCanvasItem::setAnimated(), QCanvasItem::setVelocity() and QCanvas::setAdvancePeriod() instead of using an own timer.
Thanks.
I removed my QTimer, override QCanvasText::advance() instead. But, it didn't help.
However, I adjusted the paramenter in setXVelocity() from -2 to -1 and adjusted the parameter in setAdvancedPeriod() from 50 ms to 30 ms; now, it looks much better.
Is it a solution?
Sure, if you're satisfied with the move. But the effect you had was not flicker (the picture wasn't "blinking"), the move just didn't feel smooth because of too few frames per second.
Bookmarks