[Qt-interest] Scrolling text problem
Marek Bronowicki
marek at cyberdeus.pl
Fri Nov 5 09:22:23 CET 2010
Hello
I'm making a multimedia player with information scrolls at top and
bottom of movie.
when I tried to solve "high CPU usage" I noticed that
QPainter::drawPixmap is the best for CPU...
So I'm making a couple of QPixmaps with text, and moving it - but:
it looks like drawing on the screen is from top to bottom, so moving the
pixmap from left to right using drawpixmap and paintevent of my widget
looks like the text is cut in half and one half is running after
another, and it makes it totally bad for reading.
Can anyone can guide me what to do to solve it?
for base of my widget I used this article:
http://www.informit.com/articles/article.aspx?p=1405544
void Ticker::paintEvent(QPaintEvent * /* event */)
{
QPainter painter(this);
int textWidth = fontMetrics().width(text());
if (textWidth< 1)
return;
int x = -offset;
while (x< width()) {
painter.drawPixmap(x,0,mypixmap)
x += textWidth;
}
}
this is a base paintevent from the article but it's modified to drawpixmap instead of drawtext
I also tried to not make own widget but use qgraphicsview/scene and
qgraphicspixmapitem, but it's the same. I'm not a mega developer, so I'm
sure that I didn't used a lot of solutions.
Regards,
Marek Bronowicki
More information about the Qt-interest-old
mailing list