Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Settings loading after PositionSource instantiated, wrong PluginParameter value passed
Forum Updated to NodeBB v4.3 + New Features

Settings loading after PositionSource instantiated, wrong PluginParameter value passed

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 139 Views 1 Watching
  • 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.
  • C Offline
    C Offline
    cswingle
    wrote on last edited by
    #1

    I am trying to add a baud rate setting to my QML app so that the baud rate can be changed when connecting to a NMEA GPS PositionSource. I've modified the serialnmea plugin code to accept serialnmea.baud_rate as a parameter and set the serial port baud rate appropriately. Everything works as expected when I hard code the value of the serialnmea.baud_rate PluginParameter, but when I try to set it using an ApplicationWindow property that is aliased within Settings, it doesn't use the value from Settings. It is as though the code activates the serialnmea plugin before retrieving my baud rate setting.

    I'm using Qt 5.14.2 with the serialnmea code patched to fix a bug that was corrected in 5.15.0. My code looks like this (heavily snipped):

    import QtPositioning 5.14
    import Qt.labs.settings 1.1 as AppSettings
    
    ApplicationWindow {
      id: appWindow
      property int baudRate: 4800 
      AppSettings.Settings {
        property alias baudRate: appWindow.baudRate
        Component.onCompleted: {
          console.log(`appSettings completed, baudRate = ${baudRate}`);
        }
      }
    
      PositionSource {
        id: positionSource
        name: "serialnmea"
        PluginParameter {
          name: "serialnmea.baud_rate"
          value: baudRate ? baudRate : 4800
        }
        ...
      }
    }
    

    When I run the program, the Application Output window shows the serial nmea logging output first, and a detected serialnmea.baud_rate parameter of 4800 being passed in (because baudRate is apparently zero at that point in the code execution and the ternery operator resolves to 4800). Later in the output, I see appSettings completed, baudRate = 2400, reflecting the value I've placed into settings on a previous run.

    Is there a way to delay the initiation of the PositionSource/serialnmea plugin until all the settings have been loaded?

    Or, is there a way to re-load the PositionSource once the program has started? As it is now, when a user changes the serial port (another parameter I'm passing to serialnmea), they have to restart the program in order to use the new port.

    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