Hi everybody,

As explain in the title, I (think I) have a problem with the QWidget::winId() method return value.

I am using mplayer to play movies in my application. I use the -wid argument to tell mplayer into which widget to display. I can hear sound but I can't see the video.

I did the followings tests :
* I try to run, in the command line, mplayer with the name of a movie file as the only argument ... it works fine because a window opens, and I can see the movie
* I try to do the same in my application, adding the -wid argument with the widget id ... I can hear sounds but can't see anything
* I use a specific background color for my widget in order to be sure it is shown when I request mplayer to play the movie ... I can see a square, with the specific background color where the movie (the widget itself) is supposed to be played so the widget is well shown

So, I don't understand why I can't see the movie.

Here is the code of my widget :
.h
Qt Code:
  1. #ifndef _WIDGET_VIDEO_H
  2. #define _WIDGET_VIDEO_H
  3.  
  4. #include <qwidget.h>
  5.  
  6. class QString;
  7. class QProcess;
  8.  
  9. class CWidgetVideo : public QWidget
  10. {
  11. public:
  12. CWidgetVideo(QWidget* parent=0, const char* name=0);
  13. ~WidgetVideo();
  14.  
  15. public:
  16. void StartVideo(const QString& video);
  17. void StopVideo();
  18.  
  19. private:
  20. QProcess* m_pProcessVideo;
  21. };
  22. #endif
To copy to clipboard, switch view to plain text mode 

.cpp
Qt Code:
  1. #include "WidgetVideo.h"
  2. #include <qapplication.h>
  3. #include <qstring.h>
  4. #include <qprocess.h>
  5.  
  6. CWidgetVideo::CWidgetVideo(QWidget* parent/*=0*/, const char* name/*=0*/):
  7. QWidget(parent, name),
  8. m_pProcessVideo(0)
  9. {
  10. }
  11.  
  12. CWidgetVideo::~CWidgetVideo()
  13. {
  14. StopVideo();
  15. }
  16.  
  17. void CWidgetVideo::StartVideo(const QString& video)
  18. {
  19. setBackgroundColor(QColor(255, 0, 255));
  20.  
  21. if( m_pProcessVideo )
  22. StopVideo();
  23.  
  24. m_pProcessVideo = new QProcess( this );
  25.  
  26. m_pProcessVideo->addArgument("C:\\MPLAYER\\mplayer.exe");
  27. m_pProcessVideo->addArgument("-wid");
  28. m_pProcessVideo->addArgument(QString::number((int)winId()));
  29. m_pProcessVideo->addArgument(video);
  30.  
  31. if( !m_pProcessVideo->start() )
  32. qDebug("Impossible to start");
  33. }
  34.  
  35. void CWidgetVideo::StopVideo()
  36. {
  37. if( m_pProcessVideo )
  38. {
  39. m_pProcessVideo->tryTerminate();
  40.  
  41. delete m_pProcessVideo;
  42. m_pProcessVideo = 0;
  43. }
  44. }
To copy to clipboard, switch view to plain text mode 

Finally the main application source code :
Qt Code:
  1. void TestMPlayerDialog::init()
  2. {
  3. m_pPlayer = 0;
  4. }
  5.  
  6.  
  7. void TestMPlayerDialog::starting()
  8. {
  9. QString directory = QDir::currentDirPath() + "/";
  10. QString video = QFileDialog::getOpenFileName(directory, "Video (*.avi *.wmv *.mpeg *.mov)", this, "", "");
  11.  
  12. if( video != "" )
  13. {
  14. if( m_pPlayer )
  15. {
  16. delete m_pPlayer;
  17. m_pPlayer = 0;
  18. }
  19.  
  20. m_pPlayer = new CWidgetVideo(this, "Player");
  21.  
  22. m_pPlayer->setGeometry(10, 120, 320, 240);
  23. m_pPlayer->StartVideo(video);
  24. m_pPlayer->show();
  25. }
  26. }
  27.  
  28.  
  29. void TestMPlayerDialog::stopping()
  30. {
  31. if( m_pPlayer )
  32. {
  33. m_pPlayer->StopVideo();
  34. m_pPlayer->hide();
  35.  
  36. delete m_pPlayer;
  37. m_pPlayer = 0;
  38. }
  39. }
To copy to clipboard, switch view to plain text mode 

starting and stopping are two slots called when buttons start and stop are pressed.

I hope someone could help me, thantks in advance.