Embed QML Item in QWidget
I need to have some "analog" gauges in my QWidget application. So far the best way to create the gauges appears to be QtQuick. I have never used it before, but I think I can manage to make what I need using the examples. However, I do not want to develop my whole app in QtQuick. Is it possible to create an item with its signals and slots, and the embed it into a QWidget? And is it a good idea to do so? I am reading "Integrating QML in existing QT UI code" and it looks like there is a way. But before I start, I would like to hear if I am on the right path here. I would also be grateful for any tutorials regarding this topic.
Thanks a lot
Have a look at "QQuickwidget":http://doc.qt.io/qt-5/qquickwidget.html. It can be used with other Qt Widgets. You can find an example there. There's QQuickWidget in QtCreator's widget box too just like other widgets.
Thanks for the link. I managed to get the thing working before I read this relpy using QDeclarativeView objects and adding them to a widget. I am also able to use C++ signals in the QML using rootContext()->setContextProperty. Is there any benefit if I use the QQuickWidget instead? From what I see, I will still need to have a QDeclarativeView to refer to the QML item.
QDeclarativeView is for Qt Quick 1. These are old technologies which are now deprecated.
Use QQuickWidget + Qt Quick 2 instead.
See "Porting QML Applications to Qt 5":http://doc.qt.io/qt-5/qtquick-porting-qt5.html for more info.