Hi!
I am using the arcGIS Qt/C++ template that creates a QQuickView to show an application window, and I'd like to use a menubar item. My idea was to create an Application Window in QML and set the menubar from there, but the template sets you up with a QQuickItem which cannot have an Application Window as a parent.
What other ways are there to use Application Window with this template?
Is this possible or should I find a workaround?
Thanks!!
Solved! Go to Solution.
Hi Nicholas - the template currently is not set up to provide you with an Application Window (please let me know if you think that is something important to include).
However, you can set your template up to use an ApplicationWindow with just a few changes:
in main.cpp you will need to:
1. #include <QQmlApplicationEngine> 2. replace QQuickView view; withQQmlApplicationEngine engine; 3. replace any occurrences of view.engine()-> with engine. 4. remove any other references to view In your main.qml file, wrap the existing root item in an ApplicationWindow:ApplicationWindow {visible: trueTest_application_window {width: 800height: 600// Create MapQuickView here, and create its Map etc. in C++ codeMapView {anchors.fill: parentobjectName: "mapView"// set focus to enable keyboard navigationfocus: true}}}
Don't forget to set the visible property of the ApplicationWindow to true as this will be false by default. Once you have done that you should be able to use your QQuickItem created by the template as before and add a ToolBar etc. to the parent window.
I hope that helps you get going.
Luke
Hi Nicholas - the template currently is not set up to provide you with an Application Window (please let me know if you think that is something important to include).
However, you can set your template up to use an ApplicationWindow with just a few changes:
in main.cpp you will need to:
1. #include <QQmlApplicationEngine> 2. replace QQuickView view; withQQmlApplicationEngine engine; 3. replace any occurrences of view.engine()-> with engine. 4. remove any other references to view In your main.qml file, wrap the existing root item in an ApplicationWindow:ApplicationWindow {visible: trueTest_application_window {width: 800height: 600// Create MapQuickView here, and create its Map etc. in C++ codeMapView {anchors.fill: parentobjectName: "mapView"// set focus to enable keyboard navigationfocus: true}}}
Don't forget to set the visible property of the ApplicationWindow to true as this will be false by default. Once you have done that you should be able to use your QQuickItem created by the template as before and add a ToolBar etc. to the parent window.
I hope that helps you get going.
Luke
Thank you Luke!
This worked and I think it will get me going a lot more quickly now.
Personally I do think it would be nice to include support for Application Windows with the template. They seem very helpful and it would allow for easier development of applications with multiple windows