[UNSOLVEABLE] Again problems with QWidget in QML this time HWND
-
I solved my problem, the mistake was trying to use QWidget, somehow I can set the QWidget's background through CSS and it will show up in QML, but vlc won't draw anything on it.
The solution is to use QGraphicsScene instead. Well it worked for me.
-
Hi!
I have the same problem, but I use phonon module. Can you place code with integration QGraphicsScene to Qml here? Thank you in advance! -
Sorry when I made that conclusion, I thought I could implement QGraphicsSCene with valid winId, actually you can't.
Only the main windows has valid WinId, so the VLC or maybe even phonon draws on top of the QML viewer.
I can give you code for how to implement Qgraphicscene without winid, you will be able to draw circles rectangles or anything you want. But you won't get a valid winId.
And if you use phonon, maybe check out Qt Multimedia. I once came across, that QML or Qt Quick has built in video/audio player. If I remember correctly the library was called Qt Multimedia.
-
AFAIK, there is a possibility to fore a widget to be a real windows window. Then it will have a valid winId(). I think it was something like:
@
x->setAttribute(Qt::WA_NativeWindow, true);
x->setAttribute(Qt::WA_DontCreateNativeAncestors, true);
@where x is the widget that should show the video.
as description, have a look at "native vs. alient widgets":http://doc.qt.nokia.com/latest/qwidget.html#native-widgets-vs-alien-widgets
-
Thanks...Unfortunately, player based on QtMobility, and Qml element "Video" are play stream video not correctly. That is why I use phonon modul. And recently I've learned that phonon player can output video to widget only...
-
Still, even with set attribute in qt quick my VLC plugin doesn't get a picture. If I understand correctly, when I embed QWidget in QML, it's winId technically won't exist anymore.
-
Hello
We built QML plugin that used Phonon as video play engine and it works correct in our QML project. Here are worked QML Phonon component sources:
@ class QmlVideo : public QDeclarativeItem
{
Q_OBJECT
public:
explicit QmlVideo(QDeclarativeItem *parent = 0);
public slots:
void play();
private:
Phonon::VideoPlayer *m_pPhononPlayer;
};
QmlVideo::QmlVideo(QDeclarativeItem parent) :
QDeclarativeItem(parent)
{
m_pPhononPlayer = new Phonon::VideoPlayer(Phonon::VideoCategory);
QGraphicsProxyWidget proxy = new QGraphicsProxyWidget(this);
proxy->setWidget(m_pPhononPlayer);
}void QmlVideo::play() { m_pPhononPlayer->play(QUrl("C:\\test.avi")); }
@
Now we decided to replace Phonon on another video play engine. This another video play engine draws video in external lib and requires only HWND window where to paint. So we replaced Phonon widget to usual QWidget in our QML video component and passed QWidget winId() to video lib but it doesn't work. We can hear sound but video is not visible (WM_PAINT doesn't come to this widget). Below are NOT worked QML component with using external video lib:
@ class QmlVideo : public QDeclarativeItem
{
Q_OBJECT
public:
explicit QmlVideo(QDeclarativeItem *parent = 0);
public slots:
void play();
private:
QWidget *m_pWidget;
IPlayerCore *m_pPlayerCore;
};
QmlVideo::QmlVideo(QDeclarativeItem *parent) :
QDeclarativeItem(parent)
{
m_pWidget = new QWidget();
m_pWidget->resize(300, 300);
m_pWidget->show();QGraphicsProxyWidget* proxy = new QGraphicsProxyWidget(this); proxy->setWidget(m_pWidget); } void QmlVideo::play() { WId hwnd = m_pWidget->winId(); if (CreatePlayerCore(hwnd, &m_pPlayerCore) != IPlayerCore::STATUS_OK || m_pPlayerCore == 0) { qDebug() << "Failed to create player core!\n"; } if (m_pPlayerCore->Subscribe(new IPlayerCoreNotifyImpl(hwnd, m_pPlayerCore)) < 0) { qDebug() << "Failed to subscribe to core events!\n"; } if (m_pPlayerCore->Load(false, L"C:\\test.avi") != IPlayerCore::STATUS_OK) { qDebug() << Q_FUNC_INFO << "error"; } }
@
In the same time we can see video in this m_pWidget if comment line
//proxy->setWidget(m_pWidget);
but then window is not part of QML scene.So how is to get video painted from external video lib on QWidget that will be a part of scene as QML component?
-
Well, I had this problem last summer, I 've to look for my old code. I think I solved it, but I couldn't found my source code at this moment. I think it's on my other computer.
-
Could you inform me about your search results please?
It's urgent, for a long time already can't find the solution. -
@xcoder:
would be nice to see a working example, still facing the same problems as you and Roman90. couldn't this be considered as a bug from qt side?regards ..