
Originally Posted by
jpn
Works for me with Qt 4.3.2.
Dear Sir!
I am using the following code in Qt 4.3.2.
scrItem
->setDefaultTextColor
(QColor(Qt
::red));
animation->setItem(scrItem);
float n;
int yLoc=screen.height()-(scrFont.pointSize()+40);
wScroller->setGeometry(0,yLoc,wScroller->width(),scrFont.pointSize()+40);
view->setWindowFlags (Qt::FramelessWindowHint);
view->setStyleSheet("background: transparent");
scene->addItem(ship);
scene->addItem(scrItem);
view->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
view->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
scene->setSceneRect(0,0,wScroller->width(),scrFont.pointSize()+40);
n=scrWidth;/*Width of scrText*/
qreal sh=scene->height()/2-ship->boundingRect().height()/2;
qreal h=scene->height()/2-scrItem->boundingRect().height()/2; /*Calculating the eaxact mid Y cordinate position of scrItem (Text)*/
register int scrItembrw=scrItem->boundingRect().width();
register int velNum=16;
register int velocity=(((velNum-scrSpeed)*3)-2);
register int tl=(n+scrItembrw)*velocity;
scrTime=tl;
timer
->setCurveShape
(QTimeLine::LinearCurve);
timer->setLoopCount(0);
animation->setTimeLine(timer);
animation1->setTimeLine(timer);
for (int i=0; i<(n+scrItem->boundingRect().width()); i=i+1)
{
p.setX(n-i);
p.setY(h);
ps.setX(n-i-imgbrw);
ps.setY(sh);
animation->setPosAt(i/(n+scrItem->boundingRect().width()),p);
}//end for
view->setFixedWidth(wScroller->width());
view->setFixedHeight(scene->height());
view->show();
timer->start();
QGraphicsTextItem *scrItem = new QGraphicsTextItem(scrText);
scrItem->setDefaultTextColor(QColor(Qt::red));
QGraphicsScene *scene=new QGraphicsScene();
QGraphicsItemAnimation *animation = new QGraphicsItemAnimation;
QGraphicsItemAnimation *animation1 = new QGraphicsItemAnimation;
animation->setItem(scrItem);
float n;
screen=QApplication::desktop()->screenGeometry();
int yLoc=screen.height()-(scrFont.pointSize()+40);
wScroller->setGeometry(0,yLoc,wScroller->width(),scrFont.pointSize()+40);
view=new QGraphicsView(scene,wScroller);
view->setWindowFlags (Qt::FramelessWindowHint);
view->setStyleSheet("background: transparent");
scene->addItem(ship);
scene->addItem(scrItem);
view->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
view->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
view->setCacheMode(QGraphicsView::CacheBackground);
scene->setSceneRect(0,0,wScroller->width(),scrFont.pointSize()+40);
n=scrWidth;/*Width of scrText*/
qreal sh=scene->height()/2-ship->boundingRect().height()/2;
qreal h=scene->height()/2-scrItem->boundingRect().height()/2; /*Calculating the eaxact mid Y cordinate position of scrItem (Text)*/
register int scrItembrw=scrItem->boundingRect().width();
register int velNum=16;
register int velocity=(((velNum-scrSpeed)*3)-2);
register int tl=(n+scrItembrw)*velocity;
scrTime=tl;
timer = new QTimeLine(tl);
timer->setCurveShape(QTimeLine::LinearCurve);
timer->setLoopCount(0);
animation->setTimeLine(timer);
animation1->setTimeLine(timer);
for (int i=0; i<(n+scrItem->boundingRect().width()); i=i+1)
{
QPointF p(0,h);
p.setX(n-i);
p.setY(h);
ps.setX(n-i-imgbrw);
ps.setY(sh);
animation->setPosAt(i/(n+scrItem->boundingRect().width()),p);
}//end for
view->setFixedWidth(wScroller->width());
view->setFixedHeight(scene->height());
view->show();
timer->start();
To copy to clipboard, switch view to plain text mode
but it is not working.
Bookmarks