Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Placing QQuickView in a QMainWindow?
nicky j last edited by
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?
dbzhang800 last edited by
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.