It's possible, but not adivisable, unless the Widgets in question have a lot of graphics (likely if you have a class based on QGraphivsView). If the widgets that you are refering to are "normal" QWidgets, please don't try to do this as it's more trouble than it's worth.
You need to create a new class that Inherit QQuickPaintedItem and override a few methods:
Header:
class QQmlWidget : public QQuickPaintedItem
{
Q_OBJECT
public:
explicit QMLProfile(QWidget *internalWidget, QQuickItem *parent = 0) : QQuickPaintedItem(parent), internalWidget(internalWidget){}
virtual ~QMLProfile();
void paint(QPainter *painter) override;
protected:
void mouseMoveEvent(QMouseEvent *event);
private:
QWidget *internalWidget;
};
Cpp:
(The code below is from Subsurface code, that uses QGraphivsView on QML)
void paint(QPainter* painter) {
// let's look at the intended size of the content and scale our scene accordingly
QRect painterRect = painter->viewport();
QRect profileRect = internalWidget->viewport()->rect();
qreal sceneSize = 104; // that should give us 2% margin all around (100x100 scene)
qreal dprComp = devicePixelRatio() * painterRect.width() / profileRect.width();
qreal sx = painterRect.width() / sceneSize / dprComp;
qreal sy = painterRect.height() / sceneSize / dprComp;
// next figure out the weird magic by which we need to shift the painter so the widget is shown
int dpr = rint(devicePixelRatio());
qreal magicShiftFactor = (dpr == 2 ? 0.25 : (dpr == 3 ? 0.33 : 0.0));
// now set up the transformations scale the profile and
// shift the painter (taking its existing transformation into account)
QTransform profileTransform = QTransform();
profileTransform.scale(sx, sy);
QTransform painterTransform = painter->transform();
painterTransform.translate(-painterRect.width() * magicShiftFactor ,-painterRect.height() * magicShiftFactor);
// apply the transformation
painter->setTransform(painterTransform);
internalWidget->setTransform(profileTransform);
// finally, render the profile
internalWidget->render(painter);
}
QQmlWidget::mouseMoveEvent(QMouseEvent *ev){
/* Map the eveent to the Widget */
QQuickPaintedItem(ev);
internalWidget->mouseEvent(ev);
}
As I said, doable, but not really straigthforward. Only do that if you have no way of recreating the Widgets in QML.