Results 1 to 2 of 2

Thread: Painting output of phono/video widget to QImage from worked thread in QT

  1. #1
    Join Date
    Jul 2010
    New Delhi, India
    Qt products
    Qt4 Qt/Embedded
    Unix/X11 Windows

    Default Painting output of phono/video widget to QImage from worked thread in QT

    In my QT application, I am using phonon's video widget to play video. This video widget is added to main scene using proxy widget.

    I have observed that when the video is playing, repaint messages are sent regularly to scene around 40 times in a second. Also, each call to refresh the video widget takes around 20 ms. Now if I have 5 such video widgets, then all these video widgets will send repaint commands to main view and 20*5 = 100 ms will be lost in just repainting them.

    This is causing unacceptable delay in our application when the user is interacting very quickly e.g. mouse messages in quick succession while video is playing. In 100 ms, you will on average lose around 10 mouse messages which is a lot.

    My idea is to repaint these video frames on a separate background image in a separate thread and only copy the exposed-rect part from background image to screen during paint event which will bring down the 20 ms repaint time to micro-seconds. You can consider it equivalent to video widget doing all its painting on QImage.

    For this, I created a separate thread and tried repainting the video widget onto a QImage. But my code fails inside drawWidget routine in qwidget.cpp while sending a spontaneous repaint event to widget (Line 5339, qwidget.cpp) with the error that sending events to object from thread other than owner thread is not allowed.

    Any workaround or alternate approaches to my problem?

  2. #2
    Join Date
    Jan 2006
    Warsaw, Poland
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits

    Default Re: Painting output of phono/video widget to QImage from worked thread in QT

    I don't think Phonon can paint on anything but a widget and the widget itself is controlled by another process so I'd assume you can access the wideo from the widget as well as it probably doesn't go through Qt's backbuffer. And I'm sure you know you can't paint to widgets in worker threads so using phonon there is probably out of a question.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.

Similar Threads

  1. Playing video using Phonon video widget
    By Leolander in forum Newbie
    Replies: 0
    Last Post: 26th February 2010, 06:15
  2. Phono installation on XP
    By Rajeshsan in forum Installation and Deployment
    Replies: 0
    Last Post: 28th January 2010, 05:52
  3. Gui Painting in Thread?
    By vishal.chauhan in forum Qt Programming
    Replies: 4
    Last Post: 24th July 2007, 09:24
  4. Font size calculation when painting in a QImage
    By Ishark in forum Qt Programming
    Replies: 3
    Last Post: 15th July 2007, 22:22
  5. Trouble with image painting (QPainter + QImage)
    By krivenok in forum Qt Programming
    Replies: 1
    Last Post: 4th February 2006, 20:25


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.