Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Rendering programmatically generated data
Forum Updated to NodeBB v4.3 + New Features

Rendering programmatically generated data

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 517 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I have generated a color-bar pattern and stored it in a buffer.
    How do i render/display this buffer data onto my application.

    jsulmJ 1 Reply Last reply
    0
    • ? A Former User

      I have generated a color-bar pattern and stored it in a buffer.
      How do i render/display this buffer data onto my application.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @sankar-110 See http://doc.qt.io/qt-5/qwidget.html#paintEvent
      Example: http://doc.qt.io/qt-5/qtwidgets-widgets-analogclock-example.html

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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);
        }
        

        alt text

        1 Reply Last reply
        4

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved