I have a Qt application with some buttons that, when clicked, execute its respective slot functions.
Now I want to automatically execute some of the slot functions, without clicking. So for example this does the OK action:
int main(int argc, char* argv[])
{
MFCApplication app(argc, argv);
StartDialog dialog;
dialog.slot_function_OK_button(); //Automatically clicks OK button
// initialise ROS and start spinning
ros::init(argc, argv, "platero_ros");
//ROS UI service
ros::NodeHandle n;
ros::ServiceServer service = n.advertiseService("UIservice", UIcommand);
ROS_INFO("Ready to receive ROS messages to interact with UI.");
ros::AsyncSpinner spinner(1); // start ros loop
spinner.start();
dialog.show();
return app.exec();
return 0;
}
Now instead of in the main function, I want to automatically execute the slot functions in UIcommand callbacks
//rosui
bool UIcommand(project_ros::UIservice::Request &req,
project_ros::UIservice::Response &res)
{
res.response_string = std::string(req.ui_command.c_str()) + " command was received";
// I would like to do dialog.slot_function_OK_button() here but dialog is not in this scope
ROS_INFO("%s", res.response_string.c_str());
return true;
}
How can I achieve that?