Build RViz plugin from .ui file
My existing solution simply designs the GUI in qtcreator and then use the uic
to generate the dotnect_window.h (link to plugin) which I might have to modify to derive from class ... : public rviz::Panel
. How to automate this / do it all?
For example rqt_image_view
already uses an .ui file, but it is rqt standalone. So I started with the RViz plugin teleop and added code from rqt_image_view
. Maybe I could use the uncommented qt4/5_wrap_ui
as a start? Just to give an idea:
cmake_minimum_required(VERSION 2.8.3)
project(rviz_dotnect_plugin)
# ros packages
find_package(catkin REQUIRED COMPONENTS
rviz
)
catkin_package(
# INCLUDE_DIRS
# LIBRARIES ${PROJECT_NAME}
CATKIN_DEPENDS rviz
# DEPENDS
)
include_directories(
${catkin_INCLUDE_DIRS}
include
)
link_directories(
${catkin_LIBRARY_DIRS}
)
# Bundle headers .h
set(HEADER_FILES
include/drive_widget.h
include/teleop_panel.h
)
# Automatically enable Qt's Meta-Object Compiler moc generation
set(CMAKE_AUTOMOC ON)
# Avoid keyword definition to avaid conflicts with boost or xapian etc
# e.g. http://muddyazian.blogspot.de/2012/04/getting-qt-app-working-with-boost-using.html
add_definitions(-DQT_NO_KEYWORDS)
# Use same QT version as rviz and specify headers run through MOC.
# MOC generated .cpp files are included automatically as headers.
if(rviz_QT_VERSION VERSION_LESS "5")
message(STATUS "Using Qt4 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
find_package(Qt4 ${rviz_QT_VERSION} EXACT REQUIRED QtCore QtGui)
include(${QT_USE_FILE})
qt4_wrap_cpp(HEADER_FILES_MOCS ${HEADER_FILES})
#qt4_wrap_ui(rqt_image_view_UIS_H ${rqt_image_view_UIS})
else()
message(STATUS "Using Qt5 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
find_package(Qt5 ${rviz_QT_VERSION} EXACT REQUIRED Core Widgets)
set(QT_LIBRARIES Qt5::Widgets)
qt5_wrap_cpp(HEADER_FILES_MOCS ${HEADER_FILES})
#qt5_wrap_ui(rqt_image_view_UIS_H ${rqt_image_view_UIS})
endif()
# Bundle source .cpp including the mocs
set(SOURCE_FILES
src/drive_widget.cpp
src/teleop_panel.cpp
${HEADER_FILES_MOCS}
)
# A rviz plugin is a shared library named ${PROJECT_NAME}.so
add_library(${PROJECT_NAME} ${SOURCE_FILES})
# Link executable with Qt libraries
target_link_libraries(${PROJECT_NAME}
${QT_LIBRARIES}
${catkin_LIBRARIES}
)
## Install rules...
I went on and generated the header from .ui via $ uic -o dotnect_window.h dotnect_window.ui
. But uic
deprecated the -i arg to generate the implementation file via uic -i PizzaEntry.h -o PizzaEntry.cpp pizza.ui
. Argl.
Also the third step is nowhere to be found inside rqt_image_view
.
I get confused with what is a rqt standalone and what I actually need to just get the rviz plugin asrviz::Panel
building from .ui.
You definitely shouldn't be doing the conversion from .ui files to C++ code manually; the build system should do that for you. I don't do much work with QT, but the qt4/5_wrap_ui rules look like the right place to start.