[Interest] Load Qml file in custom QmlContext with QQuickWidget

Edward Sutton edward.sutton at subsite.com
Wed Nov 18 14:36:11 CET 2015


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(new Ui::MainWindow)

  ,m_quickWidget(new QQuickWidget)

{

    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20151118/6634d364/attachment.html>


More information about the Interest mailing list