Solved How to get window handle while I use QML?
-
The initialization code is below:
int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QLatin1String("qrc:/main.qml"))); if (engine.rootObjects().isEmpty()) return -1; return app.exec(); }
where I can get the HANDLE of th "main.qml" ?
-
if( QQuickWindow* window = qobject_cast<QWindow*>( engine.rootObjects().at(0) ) ) window->winId();
(untested)
-
@raven-worx Thank you reaven
-
May be we should replace "QQuickWindow" as "QWindow"
-
@Soul
yes this is a typo .. and wouldn't compile anyway.
my first intention was to useQWindow
, since i also did the corresponding cast.