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. QRemoteObject with Android Service
Forum Updated to NodeBB v4.3 + New Features

QRemoteObject with Android Service

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
2 Posts 1 Posters 254 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.
  • B Offline
    B Offline
    BTSTOnline
    wrote on last edited by
    #1

    I can successfully create an Android service and use qRO to pass data from the service to my app... great!

    However, I cannot seem to get this to work.

    My app acts at the 'source' and the service acts as the 'client'. I need to pass some data from my app to the service once I start the service. I have tried using a SIGNAL from the 'source' to the 'client', which compiles and runs, but the SIGNAL does not appear to be received by the 'client'. I also tried using a PROP, but once I add that to my .rep, I get all sorts of errors... so the SIGNAL method seems to be my best option.

    In my .rep, I have

    SLOT(server_slot(bool clientState));
    SIGNAL(setBgFlagSignal(bool bgFlag));
    

    In my App:

    connect(this,SIGNAL(updateBgFlag(bool)), &gpsObj, SLOT(server_slot(bool)));
    bool bgFlag = false;
    emit updateBgFlag(bgFlag);
    

    My Remote Object has this:

    void GpsRemoteObject::server_slot(bool clientState)
    {
       qDebug() << "State set to: " << clientState;
       appIsForeground = !clientState;
       emit setBgFlagSignal(clientState);
       qDebug() << "Foreground set to: " << appIsForeground;
    }
    

    My Client (service):

    repNode.connectToNode(QUrl(QStringLiteral("local:gpsremote"))); // connect with remote host node
    ptr.reset(repNode.acquire<GPSRemoteObjectReplica>()); // acquire replica of source from host node
    QObject::connect(ptr.data(), SIGNAL(setBgFlagSignal(bool)),this,SLOT(setBgFlag(bool)));
    
    void Worker::setBgFlag(bool bgFlag) {
        qDebug() << "1234 bgFlag set: " << bgFlag;
        appIsBackground = bgFlag;
    }
    

    What I am not seeing... is appIsBackground being set in the setBgFlag SLOT...

    Any ideas why?

    The Client (service) passes data to the Source (and then to my app) without issues... Pretty much just the reverse of what I'm trying above. Works flawlessly.

    --Sam

    1 Reply Last reply
    0
    • B Offline
      B Offline
      BTSTOnline
      wrote on last edited by
      #2

      If I put a PROP in my .rep like so:

      PROP(bool bgFlag=false);
      

      I immediately get errors about pure virtual functions not being implemented, and my class is now abstract:
      0_1566590609553_d21dae1a-0b58-4b1e-8952-a7eb3f8ec9d1-image.png

      Ideas?

      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