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. Displaying sequence of images from separate thread
Forum Updated to NodeBB v4.3 + New Features

Displaying sequence of images from separate thread

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.6k 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.
  • K Offline
    K Offline
    karl.b
    wrote on last edited by
    #1

    Hi,

    I want to display a sequence of images with about 10-20fps using QLabel. Since the images are created by a separate thread, I use a signal/slot construction to avoid thread safety issues (see code below). All in all it works well, but some images get sporadically lost, i.e., they are not displayed. Adding a call to show() doesn't help. Any ideas what's going wrong? Thanks a lot in advance for your help and sorry if this is a newbie question!

    Regards

    @class gui: public QWidget {
    Q_OBJECT
    public:
    gui();
    void nextImage(QImage img);
    ...
    signals:
    void signalImage(QImage img);
    public slots:
    void setImage(QImage img);
    private:
    QLabel *label;
    ...
    }

    gui::gui() {
    label = new QLabel(...);
    ...
    QObject::connect(this, SIGNAL(signalImage(QImage)), this, SLOT(setImage(QImage)));
    }

    void gui::nextImage(QImage img) {
    emit signalImage(img);
    }

    void gui::setImage(QImage img) {
    label->setPixmap(QPixmap::fromImage(img));
    // label->show();
    }
    @
    Main thread:
    @ gui myGui;@

    Application thread:
    @ QImage img(...);
    myGui->nextImage(img);@

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Your code seems a bit convoluted to to achieve what you want, maybe have a look at the "mandelbrot example":http://qt-project.org/doc/qt-4.8/threads-mandelbrot.html
      It explains a similar setup as yours (although the image generation will differ)

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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