Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Show Qt layout from Android (Dream)Service?
Forum Updated to NodeBB v4.3 + New Features

Show Qt layout from Android (Dream)Service?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
2 Posts 2 Posters 282 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AnQuter
    wrote on 7 Oct 2023, 21:34 last edited by
    #1

    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.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      Daniel Rush
      wrote on 25 Nov 2024, 08:16 last edited by
      #2

      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.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved