How to integrate QML and C++
-
image will be shown in qml window
-
my question is when press any key in qml i want to get that dialog window
-
Keys.onPressed: {
if (event.modifiers & Qt.ControlModifier)
{
console.log("qml");
//when press any here i want to hide the view window
} -
@karti-gesar If I understood you correctly you want a way to close the
QQuickView
window using theKeys
item in the QML loaded by thatQQuickView
. If so then there is a globalQt
object that provides a quit method. As its description says you just have to connect that signal to yourQQuickView
'sQQmlEngine
and then callclose
onQQuickView
.
Eg.
QMLKeys.onPressed: { ... Qt.quit() ... }
CPP
view =new QQuickView; connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); or connect(view->engine(), &QQmlEngine::quit, view, &QQuickView::close);
Hope this helps...
-
i will try it
-
hereIn Qt.quit() Qt is the id name ah
-
@karti-gesar No. It is the global object available across all QML files.
http://doc.qt.io/qt-5/qml-qtqml-qt.html -
not working
-
@karti-gesar Try
import QtQml 2.2
-
@p3c0 i will try