File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,6 +48,11 @@ IF(CPP_STARTER_USE_OPEN62541)
4848 ADD_SUBDIRECTORY (open62541 )
4949ENDIF ()
5050
51+ # slint example
52+ IF (CPP_STARTER_USE_SLINT)
53+ MESSAGE ("Using slint" )
54+ ADD_SUBDIRECTORY (slint )
55+ ENDIF ()
5156
5257FIND_PACKAGE (docopt REQUIRED )
5358FIND_PACKAGE (spdlog REQUIRED )
Original file line number Diff line number Diff line change 1+ INCLUDE (FetchContent )
2+
3+ FIND_PACKAGE (Slint QUIET )
4+ IF (NOT Slint_FOUND)
5+ MESSAGE (STATUS "Slint could not be located in the CMake module search path. Downloading it from Git and building it locally" )
6+ FETCHCONTENT_DECLARE (
7+ Slint
8+ GIT_REPOSITORY https://github.com/slint-ui/slint.git
9+ GIT_TAG v1.9.2 # pin to a specific release for reproducible builds
10+ SOURCE_SUBDIR api/cpp
11+ GIT_SHALLOW TRUE # faster clone, no full history needed
12+ )
13+ FETCHCONTENT_MAKEAVAILABLE (Slint)
14+ ENDIF ()
15+
16+ ADD_EXECUTABLE (slintExample src/main.cpp )
17+ TARGET_LINK_LIBRARIES (slintExample PRIVATE Slint::Slint )
18+ SLINT_TARGET_SOURCES (slintExample ui/app-window.slint )
19+ # On Windows, copy the Slint DLL next to the application binary so that it's found.
20+ IF (WIN32 )
21+ ADD_CUSTOM_COMMAND (TARGET slintExample POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS :slintExample > $<TARGET_FILE_DIR :slintExample > COMMAND_EXPAND_LISTS )
22+ ENDIF ()
Original file line number Diff line number Diff line change 1+ #include < app-window.h>
2+
3+ int main ()
4+ {
5+ auto ui = AppWindow::create ();
6+
7+ ui->on_request_increase_value ([ui]{
8+ ui->set_counter (ui->get_counter () + 1 );
9+ });
10+
11+ ui->run ();
12+ return 0 ;
13+ }
Original file line number Diff line number Diff line change 1+ import { Button , VerticalBox } from "std-widgets.slint" ;
2+
3+ export component AppWindow inherits Window {
4+ in-out property <int > counter : 42 ;
5+ callback request-increase-value ();
6+ VerticalBox {
7+ Text {
8+ text : "Counter: \{root .counter} " ;
9+ }
10+ Button {
11+ text : "Increase value" ;
12+ clicked => {
13+ root .request-increase-value ();
14+ }
15+ }
16+ }
17+ }
You can’t perform that action at this time.
0 commit comments