Adding a new button to Fly View

Hello All,

I’m trying to add a new button to fly view under the Zoom out button.

I’ve added this code to the FlightDisplayViewWidgets.QML file(mapZoomMinus Round button is working i’ve added the navLight button) :
RoundButton { <<<< Good/Working
id: mapZoomMinus
visible: !ScreenTools.isTinyScreen && _mainIsMap
buttonImage: “/qmlimages/ZoomMinus.svg”
exclusiveGroup: _dropButtonsExclusiveGroup
z: QGroundControl.zOrderWidgets
lightBorders: _lightWidgetBorders
onClicked: {
if(_flightMap)
_flightMap.zoomLevel -= 0.5
checked = false
}
}
RoundButton { <<<<<Not Good/working :frowning:
id: navLight
visible: true
buttonImage: “/qmlimages/NavLight.svg”
exclusiveGroup: _dropButtonsExclusiveGroup
z: QGroundControl.zOrderWidgets
lightBorders: _lightWidgetBorders
onClicked: _activeVehicle.setNavLight(checked)
}

In Vehicle.h i’ve added :
Q_INVOKABLE void setNavLight(bool newStatus);

and the implementation is in Vehicle.cc.

The problem is that i’m keep getting : TypeError: Cannot call method ‘setNavLight’ of null .

Does anyone have any idea how to solve this issue??

more relevent idea:

  1. tried using also public slot and still got the same error.
  2. tried calling other QGC default function to the _activeVehicle object and still got the same error.

Any help will be highly appreciated.

Thanks,

_activeVehicle is NULL. Most possibly because you don’t have a vehicle connected yet.

Yes, this is correct :slight_smile:

Thanks for the help