From 6542643310ca7e9f9330219c0acacf64eb2e0a2c Mon Sep 17 00:00:00 2001 From: XMuli Date: Mon, 14 Mar 2022 20:13:33 +0800 Subject: [PATCH] feat: using spdlog example --- .gitmodules | 3 +++ ExPicShot/3rdparty/spdlog | 1 + ExPicShot/CMakeLists.txt | 2 ++ ExPicShot/main.cpp | 13 ++++++++++++- 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 .gitmodules create mode 160000 ExPicShot/3rdparty/spdlog diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..ea2bf84 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "ExPicShot/3rdparty/spdlog"] + path = ExPicShot/3rdparty/spdlog + url = https://github.com/gabime/spdlog.git diff --git a/ExPicShot/3rdparty/spdlog b/ExPicShot/3rdparty/spdlog new file mode 160000 index 0000000..b1478d9 --- /dev/null +++ b/ExPicShot/3rdparty/spdlog @@ -0,0 +1 @@ +Subproject commit b1478d98f017f3a7644e6e3a16fab6a47a5c26ba diff --git a/ExPicShot/CMakeLists.txt b/ExPicShot/CMakeLists.txt index 22a8ad0..62fd8ee 100644 --- a/ExPicShot/CMakeLists.txt +++ b/ExPicShot/CMakeLists.txt @@ -14,6 +14,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED) +include_directories(3rdparty/spdlog/include) # spdlog 路径,不必再添加链接库 + set(PROJECT_SOURCES main.cpp widget.cpp diff --git a/ExPicShot/main.cpp b/ExPicShot/main.cpp index c3efeb4..3276ef2 100644 --- a/ExPicShot/main.cpp +++ b/ExPicShot/main.cpp @@ -1,10 +1,21 @@ #include "widget.h" #include +#include "spdlog/spdlog.h" int main(int argc, char *argv[]) -{ +{ QApplication a(argc, argv); + + spdlog::info("Welcome to spdlog!"); + spdlog::error("Some error message with arg: {}", 1); + + spdlog::warn("Easy padding in numbers like {:08d}", 12); + spdlog::critical("Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42); + spdlog::info("Support for floats {:03.2f}", 1.23456); + spdlog::info("Positional args are {1} {0}..", "too", "supported"); + spdlog::info("{:<30}", "left aligned"); + Widget w; w.show(); return a.exec();