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. Why display an image on QLabel is faster than displaying the same image on a QGLWidget?

Why display an image on QLabel is faster than displaying the same image on a QGLWidget?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.8k Views
  • 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.
  • A Offline
    A Offline
    antonyprojr
    wrote on last edited by
    #1

    I'm writing a code to compare the speed of display the same image on QLabel and on a QGLWidget (one entire black QImage 1000x1000 pixels), but unlike that i expect, display that image on QLabel is faster than display on a QGLWidget. Why? When i use a QGLWidget it's not hardware accelerated? I'm doing something wrong? The time to display the image on QLabel is around 20ms, and on QGLWidget is around 65ms.

    My QGLWidget code:

    @
    void GLWidget::initializeGL()
    {
    }

    void GLWidget::resizeGL(int width, int height)
    {
    }

    void GLWidget::paintGL()
    {
    QTime t;
    t.start();
    QPainter painter(this);
    painter.drawImage(this->rect(), img);
    qDebug() << "GL" << t.elapsed();
    }
    @

    My QLabel code:

    @
    void MainWindow::display()
    {
    QTime t;
    t.start();
    QPixmap pixmap = QPixmap::fromImage(img);
    ui->label->setPixmap(pixmap);
    qDebug() << "Label" << t.elapsed();
    }
    @

    1 Reply Last reply
    0
    • A Offline
      A Offline
      akonradwesolutions
      wrote on last edited by
      #2

      The way your code works the image must likely be transferred to graphics memory of your graphics adapter for every drawing operation, which isn't very efficient. You might want to try QGLWidget::bindTexture and QGLWidget::drawTexture instead. Use bindTexture to prepare the image as texture in graphics memory and drawTexture each time you want to draw your image.

      1 Reply Last reply
      0

      • Login

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