Unsolved Rendering programmatically generated data
-
I have generated a color-bar pattern and stored it in a buffer.
How do i render/display this buffer data onto my application. -
-
Hi
While a custom Widget with a paintEvent is the right way, there is also the
alternative to paint on pixmap and show the image on a QLabel.
Note that you are only allowed to paint on an image this way.
Painting directly to screen will not work.
Has to be inside paintEvent then.void MainWindow::on_pushButton_released() { int h = ui->label->height(); int w = ui->label->width(); QPixmap pix(w, h); QPainter paint(&pix); pix.fill( Qt::white ); paint.setPen(QColor(0, 0, 0, 255)); int y = 0; int x = 0; int bw = 10; // bar width for (int barcount = 0; barcount < 12; ++barcount) { paint.setBrush(QColor(255 - x, 34 + x, 255, 255)); paint.drawRect(x, h - GetBarHeight(h), bw, h ); x += bw + 4; } paint.end(); ui->label->setPixmap(pix); }