[Interest] Load Qml file in custom QmlContext with QQuickWidget
Stéphane Fabry
sf at xris.eu
Thu Nov 19 09:16:11 CET 2015
My situation is a little bit more complex, I have a hierarchy of
QQmlContext like this :
QQmlEngine engine; // creates the root context
QQmlContext *context1 = new QQmlContext(engine.rootContext());
QQmlContext *context2 = new QQmlContext(engine.rootContext());
This way I have context properties to root context or to context 1, 2,
... depending on my application needs.
Now I need to load a Qml file within context1 into QQuickWidget.
(quickwidget->setSource(...) will use the engine root context.
How do I do ?
Thanks
Stéphane
Le 18-11-15 14:36, Edward Sutton a écrit :
> Disclaimer: I am learning QML with the help of others on this mailing
> list.
>
> 1. I added a QFrame to my UI.
> 2. Added the QML as an embedded resource and use it load the QQuickWidget
> 3. Add the QQuickWidget to the frame layout
>
>
>
> MainWindow::MainWindow(QWidget*parent):
> QMainWindow(parent),
> ui(newUi::MainWindow)
> ,m_quickWidget(newQQuickWidget)
> {
> ui->setupUi(this);
>
> m_quickWidget->resize(500,500);
> m_quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
> m_quickWidget->setSource(QUrl("qrc:/res/files/main.qml"));
> ui->frameQmlHost->layout()->addWidget(m_quickWidget);
> }
> -Ed
>
>
>
>> On Nov 18, 2015, at 6:21 AM, Stéphane Fabry <sf at xris.eu
>> <mailto:sf at xris.eu>> wrote:
>>
>>
>> Hi,
>>
>> I'd like to create an item within a qml context, with
>> QQmlComponent::create(QQmlContext*)
>> How to display that item into a QQuickWidget ?
>>
>> Thanks
>>
>>
>> Stéphane
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org <mailto:Interest at qt-project.org>
>> http://lists.qt-project.org/mailman/listinfo/interest
>
> This email and any files transmitted with it from The Charles Machine
> Works, Inc. are confidential and intended solely for the use of the
> individual or entity to which they are addressed. If you have received
> this email in error please notify the sender. Our company accepts no
> liability for the contents of this email, or for the consequences of
> any actions taken on the basis of the information provided, unless
> that information is subsequently confirmed in writing. Please note
> that any views or opinions presented in this email are solely those of
> the author and do not necessarily represent those of the company.
> Finally, the recipient should check this email and any attachments for
> the presence of viruses. The company accepts no liability for any
> damage caused by any virus transmitted by this email.
--
New address : starting December 5, 2015: _Rue d'Abhooz 25 - 4040 Herstal
- Belgium_
*Stéphane Fabry*, Project & IT Manager
+32 (0)4 367 07 92
*X-RIS* | /X-Ray Imaging Solutions/
www.xris.eu/contact.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20151119/840e94ff/attachment.html>
More information about the Interest
mailing list