Created
January 13, 2023 11:58
-
-
Save Kettenhoax/5e83c83ba2f8887e4fe8da121bd8b367 to your computer and use it in GitHub Desktop.
Minimal ROS rqt plugin that stores a color setting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.8) | |
project(qt_color_setting_test) | |
find_package(ament_cmake REQUIRED) | |
find_package(pluginlib REQUIRED) | |
find_package(rqt_gui_cpp REQUIRED) | |
find_package(Qt5Widgets REQUIRED) | |
add_library(${PROJECT_NAME} SHARED src/color_setting.cpp) | |
target_include_directories(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>) | |
ament_target_dependencies(${PROJECT_NAME} | |
rqt_gui_cpp | |
Qt5Widgets) | |
pluginlib_export_plugin_description_file(rqt_gui plugin.xml) | |
install( | |
TARGETS ${PROJECT_NAME} | |
EXPORT export_${PROJECT_NAME} | |
LIBRARY DESTINATION lib | |
) | |
ament_package() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "color_setting.hpp" | |
#include <iostream> | |
void ColorSetting::saveSettings( | |
qt_gui_cpp::Settings &, | |
qt_gui_cpp::Settings & instance_settings) const | |
{ | |
instance_settings.setValue("color", QColor("green")); | |
} | |
#include "pluginlib/class_list_macros.hpp" | |
PLUGINLIB_EXPORT_CLASS(ColorSetting, rqt_gui_cpp::Plugin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "rqt_gui_cpp/plugin.h" | |
class ColorSetting : public rqt_gui_cpp::Plugin | |
{ | |
public: | |
ColorSetting() = default; | |
~ColorSetting() = default; | |
void saveSettings( | |
qt_gui_cpp::Settings &, | |
qt_gui_cpp::Settings & instanceSettings) const override; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<library path="qt_color_setting_test"> | |
<class type="ColorSetting" base_class_type="rqt_gui_cpp::Plugin" /> | |
</library> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment