Writing a value to a parameter or changing the parameter value in QGC

Hello everyone, I want a parameter value to change when I press a button in qgc. I did a lot of research for this and created a code structure.
my code piece:
"cpp:
const char* VideoParameter::ServoName = “SERVO7_MAX”;

VideoParameter::VideoParameter(QObject* parent)
: QObject(parent)
{
}

void VideoParameter::sendServoPWM(int pwmValue)
{
if (vehicle ) {
if( vehicle->parameterManager()->parametersReady()) {
fact = vehicle->parameterManager()->getParameter(MAV_COMP_ID_AUTOPILOT1, ServoName);
if (fact) {
QVariant sendValue = pwmValue;
fact->setRawValue(sendValue);
qDebug() << “Servo PWM value sent:” << pwmValue;
} else {
qWarning() << “Failed to get parameter for SERVO7”;
}}
else {
qWarning() << " parameters not available";
}}
else {
qWarning() << "Vehicle not ready “;
}
}”

".h :
class VideoParameter : public QObject
{
Q_OBJECT

public:
explicit VideoParameter(QObject* parent = nullptr);

Q_INVOKABLE void sendServoPWM(int pwmValue);

private:

Fact* fact;
MultiVehicleManager* vehicleMgr = qgcApp()->toolbox()->multiVehicleManager();
Vehicle* vehicle = vehicleMgr->activeVehicle();

static const char* ServoName;

};"

I created a qmlregistertype for this class or I called the function in a button click function and gave its value, but when I press the button I get the following error: “PWM value sent: 1
Error: “Could not open resource for reading and writing.””
I haven’t processed any json files. Do I need to add such a plugin for the parameter?
I have no idea how to fix this. Can you help me with this? Thanks in advance for your help.
@Dylan_Owens

Hi, use other method for change the value of parameters.
Use Loader and Component. I can help you.

Hi, I would be grateful if you could help.