November 11, 2010

qmlMfc qmlMfc
Lab Rat
1 posts

[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

3 replies

November 11, 2010

qmlMfc qmlMfc
Lab Rat
1 posts

Here is how i am able to do that

  1. int CQtQuickMFCTestView::OnCreate(LPCREATESTRUCT lpCreateStruct)
  2. {
  3.     if (CView::OnCreate( lpCreateStruct ) == -1 )
  4.         return -1;
  5.  
  6.     widget = new QWinWidget( this );
  7.     QHBoxLayout *hbox = new QHBoxLayout( widget );
  8.  
  9.     QDeclarativeView *qmlView1 = new QDeclarativeView;
  10.     qmlView1->setSource(QUrl::fromLocalFile("dialcontrol.qml"));
  11.     hbox->addWidget( qmlView1 );
  12.  
  13.     QLabel *label = new QLabel( "Enter text:", widget );
  14.     QLineEdit *edit = new QLineEdit( widget );
  15.     hbox->addWidget( label );
  16.     hbox->addWidget( edit );
  17.  
  18.     QDeclarativeView *qmlView = new QDeclarativeView;
  19.     qmlView->setSource(QUrl::fromLocalFile("qgraphicsgridlayout.qml"));
  20.     hbox->addWidget( qmlView );
  21.  
  22.  
  23.     widget->move( 30, 30 );
  24.     widget->show();
  25.     return 0;
  26. }

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

  1. #include <QtWinMigrate/qmfcapp.h>
  2. #include <QtWinMigrate/qwinwidget.h>
  3. #include <qdeclarative.h>
  4. #include <QDeclarativeView>
  5. #include <QDeclarativeEngine>
  6. #include <QDeclarativeComponent>
  7. #include <QtWinMigrate/qwinwidget.h>
  8. #include <QtGui/QLabel>
  9. #include <QtGui/QLineEdit>
  10. #include <QtGui/QLayout>

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

November 12, 2010

Deleted Member # 4a2 Deleted Member # 4a2
Ant Farmer
1481 posts

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

March 14, 2012

SeedOfLife SeedOfLife
Lab Rat
39 posts

qmlMfc wrote:
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

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.

 
  ‹‹ [Solved] Flipable: how to trigger flipping from outside?      Connecting QML signals with Qt slots. ››

You must log in to post a reply. Not a member yet? Register here!