Hello Everyone, I have been trying to use Felgo for hot reload in a demo app. I have followed the guide but for some reason the hot reload no longer works. I can’t neither call any C++ code from the qml side, when I try to import the module I have created using qt_add_qml_module, I get errors. Here are the codes:
CMakeLists.txt file:
cmake_minimum_required(VERSION 4.1.1)
project(HireUs LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_PREFIX_PATH $ENV{FELGO_PREFIX_PATH})
find_package(FELGO REQUIRED)
set(FelgoHotReload_DIR $ENV{FELGO_HOTRELOAD_DIR})
find_package(FelgoHotReload CONFIG REQUIRED)
qt_standard_project_setup()
qt_add_executable(app MACOSX_BUNDLE src/main.cpp)
target_link_libraries(app PRIVATE Felgo FelgoHotReload)
set(QML_CUSTOMED_TYPES
customedModules/Main.qml
customedModules/DashboardWindow.qml
customedModules/TopBar.qml
customedModules/Project.qml
customedModules/ProjectNavigationBar.qml
customedModules/ProjectDescription.qml
customedModules/ProjectTopBar.qml
customedModules/ProjectList.qml
customedModules/ProjectListNavigationBar.qml
customedModules/SideBar.qml
customedModules/SideBarList.qml
customedModules/SideBarListDelegate.qml
customedModules/SearchInput.qml
customedModules/InputField.qml
customedModules/IconText.qml
customedModules/RoundedImage.qml
customedModules/RoundedButton.qml)
set(CPP_FILES src/MyCppItem.cpp src/MyCppItem.hpp)
set(ICONS)
qt_add_qml_module(
app
URI
HireUsModule
VERSION
1.0
RESOURCE_PREFIX
“/QML”
QML_FILES
${QML_CUSTOMED_TYPES}
SOURCES
${CPP_FILES}
RESOURCES
${ICONS})
target_include_directories(app PRIVATE src/)
main.cpp file:
#include <FelgoHotReload>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[]) {
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
static FelgoHotReload hotReload(&engine);
return app.exec();
}
Main.qml file:
import Felgo;
import QtQuick;
import QtQuick.Controls;
import QtQuick.Window;
import HireUsModule;
App{
MyCppItem{
id: my_cpp_item;
}
DashboardWindow {
id: dashboardWindow;
anchors.fill: parent;
}
}
MyCppItem.cpp: the c++ customed class I wanna use within the qml side. I am using QML_ELEMENT instead of using register or context property
#pragma once
#include <QObject>
#include <QtQml/qqml.h>
class MyCppItem : public QObject {
Q_OBJECT
QML_ELEMENT
public:
MyCppItem(QObject *parent = nullptr);
Q_PROPERTY(QString message READ message WRITE setMessage NOTIFY messageChanged)
QString message() const { return m_message; }
void setMessage(const QString &msg) {
if (m_message != msg) {
m_message = msg;
emit messageChanged();
}
}
signals:
void messageChanged();
private:
QString m_message = “Hello from C++!”;
};
The build was successful:
make ─╯
[ 1%] Running qmlimportscanner for app
[ 1%] Built target app_qmlimportscan
[ 3%] Copying app qml sources into build dir
[ 3%] Built target app_copy_qml
[ 5%] Built target app_copy_res
[ 5%] Built target app_autogen_timestamp_deps
[ 7%] Automatic MOC and UIC for target app
[ 7%] Built target app_autogen
[ 9%] Running AUTOMOC file extraction for target app
[ 11%] Running moc --collect-json for target app
[ 13%] Running rcc for resource app_raw_qml_0
[ 15%] Generating meta_types/qt6app_metatypes.json
[ 16%] Generating .rcc/qmlcache/app_customedModules/DashboardWindow_qml.cpp, .rcc/qmlcache/app_customedModules/DashboardWindow_qml.cpp.aotstats
[ 18%] Generating .rcc/qmlcache/app_customedModules/Main_qml.cpp, .rcc/qmlcache/app_customedModules/Main_qml.cpp.aotstats
[ 18%] Generating meta_types/qt6app_metatypes.json
[ 20%] Building CXX object CMakeFiles/app.dir/build/.rcc/qmlcache/app_customedModules/Main_qml.cpp.o
[ 22%] Building CXX object CMakeFiles/app.dir/build/.rcc/qmlcache/app_customedModules/DashboardWindow_qml.cpp.o
[ 24%] Building CXX object CMakeFiles/app.dir/build/.qt/rcc/qrc_app_raw_qml_0.cpp.o
[ 26%] Linking CXX executable app.app/Contents/MacOS/app
[100%] Built target app
This is the Felgo Log when I try to run it, at the end it says, unexpected token when I try to import HireUsModule:
Hot Reload: Sending file ../../../Felgo/Felgo/felgo_license.key (576 bytes)
Hot Reload: Sending file compile_commands.json (91738 bytes)
Hot Reload: Sending file CMakeCache.txt (67084 bytes)
Hot Reload: Sending file app.app/Contents/Info.plist (987 bytes)
Hot Reload: Sending file app.app/Contents/MacOS/app (2460624 bytes)
Hot Reload: Sending file HireUsModule/qmldir (930 bytes)
Hot Reload: Sending file HireUsModule/customedModules/ProjectNavigationBar.qml (2051 bytes)
Hot Reload: Sending file HireUsModule/customedModules/SideBarListDelegate.qml (3096 bytes)
Hot Reload: Sending file HireUsModule/customedModules/TopBar.qml (1533 bytes)
Hot Reload: Sending file HireUsModule/customedModules/SideBarList.qml (1129 bytes)
Hot Reload: Sending file HireUsModule/customedModules/ProjectListNavigationBar.qml (1950 bytes)
Hot Reload: Sending file HireUsModule/customedModules/InputField.qml (101 bytes)
Hot Reload: Sending file HireUsModule/customedModules/ProjectList.qml (237 bytes)
Hot Reload: Sending file HireUsModule/customedModules/Main.qml (224 bytes)
Hot Reload: Sending file HireUsModule/customedModules/SearchInput.qml (503 bytes)
Hot Reload: Sending file HireUsModule/customedModules/IconText.qml (872 bytes)
Hot Reload: Sending file HireUsModule/customedModules/SideBar.qml (1179 bytes)
Hot Reload: Sending file HireUsModule/customedModules/RoundedButton.qml (1061 bytes)
Hot Reload: Sending file HireUsModule/customedModules/Project.qml (560 bytes)
Hot Reload: Sending file HireUsModule/customedModules/RoundedImage.qml (1231 bytes)
Hot Reload: Sending file HireUsModule/customedModules/DashboardWindow.qml (830 bytes)
Hot Reload: Sending file HireUsModule/customedModules/ProjectDescription.qml (3035 bytes)
Hot Reload: Sending file HireUsModule/customedModules/ProjectTopBar.qml (1598 bytes)
file:build/HireUsModule/customedModules/Main.qml:5: unexpected token
When I comment the import HireUsModule, the app runs but the hot reload doesn’t work when a change occurs in the .qml files, however when I make a change in the CMakeLists.txt file, it reloads. The hot reload used to work but for some reason it doesn’t work for the .qml files anymore.

