July 7, 2012

stijn stijn
Lab Rat
2 posts

Proof of concept - QWebkit + Scrolling text on top

 

Hi,

I want to create a proof of concept of the following:

- In the background I need a webkit widget showing a web page in full screen.

- On top of this webpage I need a smooth scrolling text.

Can someone give me advise of which widgets (QLabel, QWebkit, …?) and which technologies (QAnimation, QOpenGL, …?) I best use to implement this proof of concept?

Thanks in advance!
Stijn.

1 reply

July 31, 2012

stijn stijn
Lab Rat
2 posts

Hi all,

Is there no one who can help me futher with this?

I implemented a scrolling text like this (see below), but it is very choppy. Does someone knows why, or could help me with this?

  1. GLWidget::GLWidget(Helper *helper, QWidget *parent)
  2.     : QGLWidget(QGLFormat(QGL::SampleBuffers), parent), helper(helper)
  3. {
  4.     elapsed = 0;
  5.     setFixedSize(1080, 200);
  6.     setAutoFillBackground(false);
  7. }
  8. //! [0]
  9.  
  10. //! [1]
  11. void GLWidget::animate()
  12. {
  13.     elapsed = (elapsed + qobject_cast<QTimer*>(sender())->interval()) % 1000;
  14.     repaint();
  15. }
  16. //! [1]
  17.  
  18. //! [2]
  19. void GLWidget::paintEvent(QPaintEvent *event)
  20. {
  21.     QPainter painter;
  22.     painter.begin(this);
  23.     painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
  24.     helper->paint(&painter, event, elapsed);
  25.     painter.end();
  26. }

  1. Helper::Helper()
  2. {
  3.     QLinearGradient gradient(QPointF(50, -20), QPointF(80, 20));
  4.     gradient.setColorAt(0.0, Qt::white);
  5.     gradient.setColorAt(1.0, QColor(0xa6, 0xce, 0x39));
  6.  
  7.     background = QBrush(QColor(64, 32, 64));
  8.     circleBrush = QBrush(gradient);
  9.     circlePen = QPen(Qt::black);
  10.     circlePen.setWidth(1);
  11.     textPen = QPen(Qt::white);
  12.     textFont.setPixelSize(150);
  13.  
  14.     xpos = 0;
  15. }
  16. //! [0]
  17.  
  18. //! [1]
  19. void Helper::paint(QPainter *painter, QPaintEvent *event, int elapsed)
  20. {
  21.  
  22.  
  23.     painter->fillRect(event->rect(), background);
  24.  
  25.     painter->setPen(textPen);
  26.     painter->setFont(textFont);
  27.  
  28.  
  29.     painter->drawText(1080 - xpos,120,"THIS IS SAMPLE TEXT");
  30.  
  31.     xpos++;
  32.  
  33.     if(xpos == (1080 + qfontmetrics.size(0, "THIS IS SAMPLE TEXT").width())) {
  34.         xpos = 0;
  35.     }
  36. }

 
  ‹‹ Edit vector elements when QListWidget Item is edited      EventFilter Print Screen key? ››

You must log in to post a reply. Not a member yet? Register here!