Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

Smooth Text Scrolling

$
0
0
Hi all, I’m looking to build a text scrolling app and I’m having a very bad performance animation. The animation isn’t smooth as it jumps like a rabbit… I really don’t understand why this simple example is not working well. Anyone can help? Here you have the code I’m using to test the minimal function. I think it’s implemented in the way the documentation recommends. #include <QtGui>   class MainWindow : public QMainWindow { Q_OBJECT   public: explicit MainWindow(QWidget *parent = 0) : QMainWindow(parent){ QVBoxLayout* layout = new QVBoxLayout();   pushButton = new QPushButton("start"); textEdit = new QTextEdit(); layout->addWidget(textEdit); layout->addWidget(pushButton); QWidget* central = new QWidget(); central->setLayout(layout); setCentralWidget(central); connect(pushButton, SIGNAL(clicked()),SLOT(start())); }   QGraphicsView* view; QGraphicsTextItem * text ; QGraphicsScene* scene; QPushButton* pushButton; QTextEdit* textEdit;   public slots:   void start(){ scene = new QGraphicsScene(); text = new QGraphicsTextItem(); text->setDocument(textEdit->document()); text->scale(6,6); text->setPos(-100,0); text->setTextWidth(140);   scene->addItem(text); scene->setSceneRect(0,0,400,400); view = new QGraphicsView(scene); view->fitInView(view->sceneRect(),Qt::KeepAspectRatio); view->setRenderHint(QPainter::SmoothPixmapTransform); view->showFullScreen();   // the important part: QPropertyAnimation *anim = new QPropertyAnimation(text, "pos", text); anim->setStartValue(text->pos()); anim->setEndValue(QPointF(-100, -1000)); anim->setDuration(5000); anim->start(); } };   #include "main.moc"   int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show();   return a.exec(); }

Viewing all articles
Browse latest Browse all 18427

Trending Articles