Unsolved how to Integrat QML in QWidget App ?
-
I am new to Qt and QML,so please in detail :
- QQuickView
2.QQuickWidget
- QQuickView
-
Hi @Alex_wang
The docs are quite self-explanatory (QQuickView and QQuickWidget.
QQuickView is used to load a QML scene given a URL whereas QQuickWidget also does the same but it can be embedded into existing QWidget. So if you want a mixture of QWidgets and QtQuick useQQuickWidget
. -
Hi
Maybe this book
https://qmlbook.github.io/
would be great to browse first before coding. -
I want to render YUV video with QOpenglWidget,and render a control UI via QML that will display upon the video.
But the control UI should be translucent so that we can see the video under it.If I use the QQuickWidget, have to the control UI translucent by the step:
QQuickWidget *view = new QQuickWidget(this);//this->QOpenglWidget view->setAttribute(Qt::WA_AlwaysStackOnTop, true); view->setClearColor(QColor(Qt::transparent));
this is valid, but I find a Transparent stripe inside the control UI.
anyone ideas ? -
This limitation only applies when there are other widgets underneath the QQuickWidget inside the same window. Making the window semi-transparent, with other applications and the desktop visible in the background, is done in the traditional way: Set Qt::WA_TranslucentBackground on the top-level window, request an alpha channel, and change the Qt Quick Scenegraph's clear color to Qt::transparent via setClearColor().
Not sure but can you try setting Qt::WA_TranslucentBackground (using setAttribute) as well as alpha channel using
setFormat
(QSurfaceFormat) ? -
I have tried,butt it is still failing!
QQuickWidget *view = new QQuickWidget(this);//this->QOpenglWidget view->setAttribute(Qt::WA_AlwaysStackOnTop, true); view->setClearColor(QColor(Qt::transparent)); view->setAttribute(Qt::WA_TranslucentBackground); view->setSource(QUrl("qrc:/main.qml")); view->show();
main.qml:
Item { opacity: 0.8 }
I find that when I do not set opacity to 0.8 in QML , the control UI is not transparent;
but when I set opacity to 0.8 in QML, the control UI is slight transparent ,
and the error with a transparent stripe appears. -
@Alex_wang Can you also try to
setFormat
with alpha channel forQQuickWidget
? Smthing like:QSurfaceFormat format; format.setAlphaBufferSize(8);
-
QQuickWidget *view = new QQuickWidget(this);//this->QOpenglWidget QSurfaceFormat format; format.setAlphaBufferSize(8); format.setDepthBufferSize(32); view->setFormat(format); view->setAttribute(Qt::WA_AlwaysStackOnTop, true); view->setClearColor(QColor(Qt::transparent)); view->setAttribute(Qt::WA_TranslucentBackground); view->setSource(QUrl("qrc:/main.qml")); view->show();
It is no effect! ..............when I not set opacity to 0.8 in QML
-
@Alex_wang Hmm, as the docs says there are some limitations to it. There are ways which we tried but it still doesn't work. I would suggest to ask this question to mailing list.