Set qml to be precompiled

This commit is contained in:
2025-03-08 17:23:29 +01:00
parent 08063e8312
commit 68ea794119
7 changed files with 56 additions and 30 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
log
install
# ---> C++
# Prerequisites
*.d

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.10)
project(rqt_demo_plugin)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
@ -16,10 +16,12 @@ find_package(Qt5 COMPONENTS Core REQUIRED)
find_package(Qt5 COMPONENTS Widgets REQUIRED)
find_package(Qt5 COMPONENTS Qml REQUIRED)
find_package(Qt5 COMPONENTS Quick REQUIRED)
find_package(Qt5QuickCompiler)
set(CMAKE_AUTOMOC ON)
set(QT_QML_GENERATE_QMLLS_INI ON)
qt_wrap_cpp(MOC_FILES include/rqt_demo_plugin/rqt_demo_plugin.hpp)
qt5_add_resources(RCC_SOURCES "resources/res.qrc")
qtquick_compiler_add_resources(RCC_SOURCES "resources/res.qrc")
add_library(

View File

@ -21,21 +21,19 @@ class DemoPluginMg : public rqt_gui_cpp::Plugin {
Q_OBJECT
public:
DemoPluginMg();
~DemoPluginMg();
virtual void shutdownPlugin() {
RCLCPP_INFO(node_->get_logger(), "The plugin has been shutdown");
cleanupResources();
}
virtual void initPlugin(qt_gui_cpp::PluginContext &);
};
inline void DemoPluginMg::initPlugin(qt_gui_cpp::PluginContext &pc) {
initResources();
QQuickView *qv = new QQuickView(QUrl("qrc:/qml/helloworld.qml"));
qv->setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView);
QWidget *qw = QWidget::createWindowContainer(qv);
pc.addWidget(qw);
RCLCPP_INFO(node_->get_logger(), "The plugin has been initialized");
QWidget *qw_ = QWidget::createWindowContainer(qv);
pc.addWidget(qw_);
}
}; // namespace mg

View File

@ -1 +1 @@
build_2025-03-07_23-29-50
build_2025-03-08_17-19-32

View File

@ -13,7 +13,7 @@
<depend>pluginlib</depend>
<depend>rqt</depend>
<depend>rqt_gui_cpp</depend>
<depend>rqt_image_view</depend>
<export>
<build_type>ament_cmake</build_type>

View File

@ -1,22 +1,48 @@
import QtQuick 2.3
Item {
Row {
anchors.right: parent.right
spacing: 4
Rectangle {
color: "gray"
Flickable {
width: parent.width;
height: parent.height
contentWidth: 2500; contentHeight: 1500
flickDeceleration: 10000
leftMargin: Math.max((width - contentWidth)/2,0)
topMargin: Math.max((height - contentHeight)/2,0)
clip: true
Rectangle {
height: 100
width: 100
color: "green"
Text {
text: "Hello, World!"
}
}
Rectangle {
height: 100
width: 100
color: "red"
Text {
text: "Hello, World!"
color: "white"
id: contentRect
anchors.top: parent.top
anchors.left: parent.left
width: parent.width
height: parent.height
transform: Scale {yScale: 1; xScale: 1}
transformOrigin: Item.TopLeft
Row {
x:0
y:0
spacing: 4
Rectangle {
height: 100
width: 100
color: "green"
Text {
text: "Hello, World!"
}
}
Rectangle {
height: 100
width: 100
color: "red"
Text {
text: "Hello, World!"
}
}
}
}
}

View File

@ -6,10 +6,8 @@
PLUGINLIB_EXPORT_CLASS(mg::DemoPluginMg, rqt_gui_cpp::Plugin)
mg::DemoPluginMg::DemoPluginMg() : Plugin() {
initResources();
QSurfaceFormat fmt;
fmt.setSwapInterval(0);
fmt.setRenderableType(QSurfaceFormat::OpenGLES);
QSurfaceFormat::setDefaultFormat(fmt);
}
mg::DemoPluginMg::~DemoPluginMg() { cleanupResources(); }
}