ScoOteR
13th February 2007, 10:47
Hay Fellows,
I'm trying to make some thing like stock ticker here, but i have problem with the rendering behavior. I've attached a sample video of the run. Any wayz, i'm having a timer that fires each 30 msecs, on the fire it calls animate() - connected with a direct connection - which updates the translation variable and calls update().
In the PaintEvent(), i starts the translations and rendering the ticker items. If any one please could help me here.
void CSymbolsTicker::animate()
{
qreal last = m_rTranslationStep * m_itime * 0.0001;
m_itime = (m_itime + qobject_cast<QTimer*>(sender())->interval()) % 1000;
qreal current = m_rTranslationStep * m_itime * 0.0001;
current -= last;
if(current * m_iDirection < 0)
current = m_rDiff;
else
m_rDiff = current;
m_rTranslationX += m_rDiff;
.....
update();
}
void CSymbolsTicker::paintEvent(QPaintEvent *event)
{
CTicker::paintEvent(event);
m_pPainter->begin(this);
m_pPainter->setRenderHint(QPainter::TextAntialiasing/*QPainter::Antialiasing*/);
m_pPainter->setFont(m_Font);
m_pPainter->translate(m_rTranslationX,0);
for (int i=0;i<m_vSymbols.count();++i)
{
m_rCurrentTranslationStep = m_vSymbols[i]->GetWidth() * -1;
if(InViewPort())
{
SetPen(m_vSymbols[i]->GetStatus());
m_vSymbols[i]->paint(m_pPainter,event,height());
m_pPainter->translate(m_rCurrentTranslationStep,0);
}
}
m_pPainter->end();
}
I'm trying to make some thing like stock ticker here, but i have problem with the rendering behavior. I've attached a sample video of the run. Any wayz, i'm having a timer that fires each 30 msecs, on the fire it calls animate() - connected with a direct connection - which updates the translation variable and calls update().
In the PaintEvent(), i starts the translations and rendering the ticker items. If any one please could help me here.
void CSymbolsTicker::animate()
{
qreal last = m_rTranslationStep * m_itime * 0.0001;
m_itime = (m_itime + qobject_cast<QTimer*>(sender())->interval()) % 1000;
qreal current = m_rTranslationStep * m_itime * 0.0001;
current -= last;
if(current * m_iDirection < 0)
current = m_rDiff;
else
m_rDiff = current;
m_rTranslationX += m_rDiff;
.....
update();
}
void CSymbolsTicker::paintEvent(QPaintEvent *event)
{
CTicker::paintEvent(event);
m_pPainter->begin(this);
m_pPainter->setRenderHint(QPainter::TextAntialiasing/*QPainter::Antialiasing*/);
m_pPainter->setFont(m_Font);
m_pPainter->translate(m_rTranslationX,0);
for (int i=0;i<m_vSymbols.count();++i)
{
m_rCurrentTranslationStep = m_vSymbols[i]->GetWidth() * -1;
if(InViewPort())
{
SetPen(m_vSymbols[i]->GetStatus());
m_vSymbols[i]->paint(m_pPainter,event,height());
m_pPainter->translate(m_rCurrentTranslationStep,0);
}
}
m_pPainter->end();
}