How to integrate QML and C++
-
Hi all...help....i have dialog and qml ..i have create a button in a dialog window if i press a button qml image will shown with help of Quickview
-
my question if i press any button in qml i want to quit that view back to the dialog
-
@karti-gesar
Is itQDialog
from Cpp and are you talking aboutQQuickView
orQQuickWidget
?
How did you callQQuickView
fromQDialog
? -
dialog in cpp and Qtquick in qml
-
view =new QQuickView();
view->setSource(QUrl("qrc:/icons/main.qml"));
imgsource<<"file:///E:/additional's/file4.jpg";
view->show();
when button is pressed this some or this will shown -
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