Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. ROS2 Humble with QML
Forum Updated to NodeBB v4.3 + New Features

ROS2 Humble with QML

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 1 Posters 412 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ROS2 Humble with QML
    wrote on last edited by
    #1

    Hi!
    I'm having an issue when compiling the code.
    I think the problem is with the paths because the CMakeLists.txt file doesn’t recognize the things related to Qt.

    cmake_minimum_required(VERSION 3.16)  # Cambia a 3.16 o superior
    
    project(hello LANGUAGES CXX)
    
    # Configuraciones de CMake para Qt
    set(CMAKE_AUTOUIC ON)
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTORCC ON)
    
    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    
    # Encuentra los paquetes de Qt y ROS2 necesarios
    find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Quick Core Gui Qml)
    find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Quick Core Gui Qml)
    find_package(rclcpp REQUIRED)
    find_package(ament_cmake REQUIRED)
    find_package(std_msgs REQUIRED)
    find_package(example_interfaces REQUIRED)
    find_package(geometry_msgs REQUIRED)
    
    # Agrega los archivos QML y de recursos
    qt_add_qml_module(example2
        URI hello
        VERSION 1.0
        QML_FILES
            qml/Home.qml
            qml/ApplicationFlow.qml
            qml/Colors.qml
            qml/Constants.qml
            qml/HomeForm.ui.qml
            qml/IP.qml
            qml/IPForm.ui.qml
            qml/main.qml
        RESOURCES
            images/logo.png
    )
    
    # Define el ejecutable y especifica los archivos fuente
    add_executable(example2
      main.cpp
      lib/rosnode.h
      src/rosnode.cpp
      src/utils.cpp
      lib/utils.h
    )
    
    # Vincula las bibliotecas de Qt y ROS2 necesarias
    target_link_libraries(example2
        Qt${QT_VERSION_MAJOR}::Quick
        Qt${QT_VERSION_MAJOR}::Core
        Qt${QT_VERSION_MAJOR}::Gui
        Qt${QT_VERSION_MAJOR}::Qml
    )
    
    # Define las dependencias de ament para ROS2
    ament_target_dependencies(example2
        rclcpp
        std_msgs
        example_interfaces
        geometry_msgs
    )
    
    # Configuración de instalación
    include(GNUInstallDirs)
    install(TARGETS example2
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    )
    
    # Define el paquete ament
    ament_package()
    

    And the path are this:
    5f35d8d4-2d85-4d7b-9c0a-af098fbb0d05-image.png

    R 1 Reply Last reply
    0
    • R ROS2 Humble with QML

      Hi!
      I'm having an issue when compiling the code.
      I think the problem is with the paths because the CMakeLists.txt file doesn’t recognize the things related to Qt.

      cmake_minimum_required(VERSION 3.16)  # Cambia a 3.16 o superior
      
      project(hello LANGUAGES CXX)
      
      # Configuraciones de CMake para Qt
      set(CMAKE_AUTOUIC ON)
      set(CMAKE_AUTOMOC ON)
      set(CMAKE_AUTORCC ON)
      
      set(CMAKE_CXX_STANDARD 17)
      set(CMAKE_CXX_STANDARD_REQUIRED ON)
      
      
      # Encuentra los paquetes de Qt y ROS2 necesarios
      find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Quick Core Gui Qml)
      find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Quick Core Gui Qml)
      find_package(rclcpp REQUIRED)
      find_package(ament_cmake REQUIRED)
      find_package(std_msgs REQUIRED)
      find_package(example_interfaces REQUIRED)
      find_package(geometry_msgs REQUIRED)
      
      # Agrega los archivos QML y de recursos
      qt_add_qml_module(example2
          URI hello
          VERSION 1.0
          QML_FILES
              qml/Home.qml
              qml/ApplicationFlow.qml
              qml/Colors.qml
              qml/Constants.qml
              qml/HomeForm.ui.qml
              qml/IP.qml
              qml/IPForm.ui.qml
              qml/main.qml
          RESOURCES
              images/logo.png
      )
      
      # Define el ejecutable y especifica los archivos fuente
      add_executable(example2
        main.cpp
        lib/rosnode.h
        src/rosnode.cpp
        src/utils.cpp
        lib/utils.h
      )
      
      # Vincula las bibliotecas de Qt y ROS2 necesarias
      target_link_libraries(example2
          Qt${QT_VERSION_MAJOR}::Quick
          Qt${QT_VERSION_MAJOR}::Core
          Qt${QT_VERSION_MAJOR}::Gui
          Qt${QT_VERSION_MAJOR}::Qml
      )
      
      # Define las dependencias de ament para ROS2
      ament_target_dependencies(example2
          rclcpp
          std_msgs
          example_interfaces
          geometry_msgs
      )
      
      # Configuración de instalación
      include(GNUInstallDirs)
      install(TARGETS example2
          LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
          RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
      )
      
      # Define el paquete ament
      ament_package()
      

      And the path are this:
      5f35d8d4-2d85-4d7b-9c0a-af098fbb0d05-image.png

      R Offline
      R Offline
      ROS2 Humble with QML
      wrote on last edited by
      #2

      @ROS2-Humble-with-QML
      The error are:

      CMakeLists.txt:24: error: Unknown CMake command "qt_add_qml_module".
      

      the version I used is CMake 3.29.3
      Qt 6.7.2

      1 Reply Last reply
      0
      • R Offline
        R Offline
        ROS2 Humble with QML
        wrote on last edited by
        #3

        My conclusion is don't do this because the cmakes is different in both so try to separete it

        1 Reply Last reply
        0
        • R ROS2 Humble with QML has marked this topic as solved on

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved