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. [SOLVED] Best method to display a stream of QImage's
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Best method to display a stream of QImage's

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.8k 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.
  • T Offline
    T Offline
    Timmoth
    wrote on last edited by
    #1

    Hi all, id like to know which method is the most efficient to display Qimages - i have tried both and they seem pretty similar so far and want to know if there are ways to optimize them, or different better methods to go about this.
    #1 having a QLabel in my QVBoxLayout and calling:
    @canvas->setPixmap(QPixmap::fromImage(img));@
    whenever there is a new frame.
    #2 using a QGraphicsView in my QVBoxLayout and then using
    @
    scene->clear();
    scene->addPixmap(QPixmap::fromImage(img));
    @

    both seem pretty CPU intensive.
    Thanks, Tim.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      puksec
      wrote on last edited by
      #2

      I would go with QGraphicsView, and draw QImages in its paint event.

      @ QImage img;
      QPainter p(this);
      p.drawImage(rect(), img);@

      You could set some flags like: @p.setRenderHint(QPainter::SmoothPixmapTransform, true);@

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Timmoth
        wrote on last edited by
        #3

        Thanks, i did end up doing that - except i just have a QGraphicsItem which i keep calling
        @
        QGraphicsPixmapItem::setPixmap(QPixmap::fromImage(img));
        @

        Is this way going to be more or less as quick as your paint method?

        also what exactly would that flag do?

        1 Reply Last reply
        0
        • P Offline
          P Offline
          puksec
          wrote on last edited by
          #4

          I don't know about the speed, its could be just as fast I guess. The method I suggested draws an image under 1ms. The flag I mentioned is used to get a better quality when scaling image.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            Timmoth
            wrote on last edited by
            #5

            Ok cheers Puksec! i might as well give both of them a go!

            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