Cannot include QDeclarative Item
-
[quote author="JKSH" date="1424387370"]* Component.onCompleted is a signal handler.
- onClicked is a signal handler.
You cannot put a signal handler inside another signal handler. You need to move Component.onCompleted up one level, at least.
[/quote]Right. I missed that one.
-
Okay but i have two call two c++ functions, and one should be called when the user clicks on the main image so i cant use component.oncompleted thn?
-
Call that function in onClicked event handler. Component.onCompleted is called after the object has been instantiated. You can call the function inside it also but since you need to do it on click, call it inside onClicked.
-
[quote author="Javeria" date="1424418592"]Okay but i have two call two c++ functions, and one should be called when the user clicks on the main image so i cant use component.oncompleted thn?[/quote]As the name implies, Component.onCompleted runs when the component has finished loading.
Do you want your function to be called when the component finishes loading?
-
And also i have changed my detectsquare function's parameters to Qimage
so that i could use the current selected image in that function but i dont understand how i should do that in QML? As i cant use Qimage object in QML -
Since you already have paths, you can just send the path string from QML to C++ and then there access that image.
-
But I want to edit that image and send it back to qml so that it displays it in the ui
-
Do you have paths for the Images in QML ?
If yes, then as said earlier, send the path string from QML to C++, open the image, process it, on C++ side(or whatever operations), then signal QML to display that image.
-
Read the blog post and the comments at http://pusling.com/blog/?p=369
-
I have decided to use Qstring and i have followed this link to assign path:
Link: http://doc.qt.io/qt-5/qtqml-cppintegration-exposecppattributes.html (The properties part)
But im getting this error
Invalid attached object assignmentQQmlComponent: Component is not ready
-
@onClicked: {
m.image=imagesListModel[index];
main.source=m.imagesListModel[index]// console.log("User select '"+"' image"); }@
m is the Detectsquares object and i m setting the path and then assigning the path to the main image
Here is the code im main.cpp:
@
QApplication app(argc, argv);
// QQmlEngine eng;QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); DetectSquares m; engine.rootContext()->setContextProperty("m",&m); QQmlComponent component(&engine, QUrl::fromLocalFile("qrc:/main.qml")); component.create();
@