Placing QQuickView in a QMainWindow?
How can I place a QQuickView in a main window? I have tried this code but it doesn't work (it works for QDeclarativeView though)
@hud::hud(QWidget *parent) :
this->setAttribute( Qt::WA_TranslucentBackground );
//this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
QQuickView *hudView = new QQuickView; hudView->setSource(QUrl::fromLocalFile("/Users/nick/Desktop/Development/QT dev/hud_v4/hud.qml")); hudView->setStyleSheet( "background-color:rgba(255,255,255,0.0);" ); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(hudView); this->setLayout(layout); setCentralWidget(hudView);
Obviously this code doesn't work. What is the proper way to add the QQuickView to the QMainWindow?
QQuickView a subclass of QWindow, but QWidget is needed when you want to add it to QMainWindow.
So QWidget::createWindowContainer() will be useful for you.