Show Qt layout from Android (Dream)Service?
-
Hi all,
so I'm wondering how could I have a DreamService display layout in Android app by using Qt/QML code instead of Java/Kotlin?
I wrote my simple "screensaver" app as expected in Qt/QML. It runs great on AndroidTV, showing simple images.
Now to have it show as a screensaver one has to write a corresponding service for it.
This is relevant part of DreamService that I have running as part of my Qt application following official docs.public class MyDream extends DreamService { @Override public void onAttachedToWindow() { super.onAttachedToWindow(); // Exit dream upon user touch setInteractive(false); // Hide system UI setFullscreen(true); // Set the dream layout // setContentView(R.layout.dream); - how to use Qt app layout? } }
This all goes well in a sense that it starts and runs that code but
the point is that I don't want to create another XML layout and write Java code for this.
I would like to obviously write/reuse regular Qt/QML code which I already wrote as part of "regular" main app that ends up creating a default layout that Qt internally uses on android to render all the UI.Now I was trying to set again the main Qt layout but using setContentView in different ways (e.g. this.getWindow().getDecorView().getRootView() and then child layouts) but I end up with "The specified child already has a parent. You must call removeView() on the child's parent first" which makes sense as I'm trying to add the same layout that my Qt activity already has.
I don't see a "xml" layout in Qt android sources or elsewhere which I could again inflate for Qt app to use with my code.
I see QtLayout internally in Qt android source code but I have no clue if I'm expected to reuse it in some way.What is the way to "force" showing main Qt activity/layout from Java so I can just write Qt/QML code?
Thanks.
-
Hi, AnQuter,
Is your question solved?
// setContentView(R.layout.dream); - how to use Qt app layout?How can I load Qt mainwindow.ui in java code?
Thanks a lot.