@J.Hilk Hey, Thank you for all of your help. Solved the problem thanks to you!
If there is anyone facing the same issue, solved like this,
Created a source file named "restarter"
restarter.h
restarter.cpp (note: my application works as a service named "myservice" on system, so I can not restart it as restarting a regular application.)
#include "restarter.h" #include <QProcess> Restarter::Restarter(QObject *parent) : QObject (parent) { } void Restarter::makeRestart() { QProcess::execute("sudo service myservice restart"); }If your application works NOT AS A SERVICE, BUT AN APPLICATION,
restarter.cpp
You need to register "restarter.cpp" as a QML registery (I know, stupid sentence)
So you need to insert these lines in main.cpp
and use it on your QML file:
import closx.restarter 1.0 Restarter { id:restarter } Rectangle{ id: restartbg width: 120 height: 70 radius: 8 color:"black" anchors.centerIn: parent z:344 Text{ anchors.centerIn: parent text:qsTr("Restart") + mytrans.emptyString font.family:GSystem.myriadproita.name font.pixelSize: 18 color: "white" } MouseArea{ anchors.fill: parent onClicked: { restarter.makeRestart() } onPressed: { restartbg.color = "#1c1c1c" } onReleased: { restartbg.color = "black" } } }Again, thanks to @LeLev and @J-Hilk for everything.