Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[Solved] QML in MFC app



  • Hello All
    I am new to QT/QML would like to know, is it possible to use QML with in existing MFC app?

    Please let me know

    Thanks & Regards



  • Here is how i am able to do that

    @int CQtQuickMFCTestView::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
    if (CView::OnCreate( lpCreateStruct ) == -1 )
    return -1;

    widget = new QWinWidget( this );
    QHBoxLayout *hbox = new QHBoxLayout( widget );
    
    QDeclarativeView *qmlView1 = new QDeclarativeView;
    qmlView1->setSource(QUrl::fromLocalFile("dialcontrol.qml"));
    hbox->addWidget( qmlView1 );
    
    QLabel *label = new QLabel( "Enter text:", widget );
    QLineEdit *edit = new QLineEdit( widget );
    hbox->addWidget( label );
    hbox->addWidget( edit );
    
    QDeclarativeView *qmlView = new QDeclarativeView;
    qmlView->setSource(QUrl::fromLocalFile("qgraphicsgridlayout.qml"));
    hbox->addWidget( qmlView );
    
    
    widget->move( 30, 30 );
    widget->show();
    return 0;
    

    }@
    CQtQuickMFCTestView is the main view class
    widget is defined in QtQuickMFCTestView.h
    also i am using qtwinmigrate project
    following are my includes

    @#include <QtWinMigrate/qmfcapp.h>
    #include <QtWinMigrate/qwinwidget.h>
    #include <qdeclarative.h>
    #include <QDeclarativeView>
    #include <QDeclarativeEngine>
    #include <QDeclarativeComponent>
    #include <QtWinMigrate/qwinwidget.h>
    #include <QtGui/QLabel>
    #include <QtGui/QLineEdit>
    #include <QtGui/QLayout>
    @

    I will add more detail (or a wiki article) as soon as i got some time



  • hi qmlMfc, you should create a wiki article for this :)
    also, can you markup the code using the @tag, will be easier to read



  • [quote author="qmlMfc" date="1289515139"]Here is how i am able to do that

    ....

    I will add more detail (or a wiki article) as soon as i got some time[/quote]

    I hope u can do this soon. I am looking to integrate part of my mfc solutions with Qt, but failing without a proper tutorial. The available QtWinMigrate project doesnt help much in my case.



  • Does this work? Has anyone tried this using QT 5.4 and MFC? Please let me know.

    Thanks and regards,
    Karrtik



  • Does this work? Has anyone tried this using QT 5.4 and MFC? Please let me know.

    Thanks and regards,
    Karrtik


Log in to reply