本帖最后由 qq710456249 于 2023-3-7 11:10 编辑
大佬们好啊, 新人学Qt, 在 Update Transactions 时不成功, 提示如下
lupdate warning: no TS files specified. Only diagnostics will be produced.
Cmakelist如下
cmake_minimum_required(VERSION 3.5)
project(Cash VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools)
# 输出目录
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/../bin)
# 自动添加文件
file(GLOB PROJECT_SOURCES
"*/*.h"
"*/*.cpp"
"*/*.hpp"
"*/*.ui"
"*/*.qrc"
"*/*/*.ts"
"*.pro"
)
# 手动添加文件
#set(PROJECT_SOURCES
# Sources/main.cpp
# Sources/mainwindow.cpp
# Sources/mainwindow.h
# Sources/mainwindow.ui
# Sources/editaccount.cpp Sources/editaccount.h Sources/editaccount.ui
# Sources/find.cpp Sources/find.h Sources/find.ui
# Sources/preferences.cpp Sources/preferences.h Sources/preferences.ui
# Sources/print.cpp Sources/print.h Sources/print.ui
# ${TS_FILES}
#)
# 翻译,cmake 未解决,使用 qmake 生成,需要将文件手动添加至 Cash.pro
set(TS_FILES Resources/po/Cash_zh_CN.ts)
qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR}/Sources ${TS_FILES})
qt_add_executable(Cash
# MANUAL_FINALIZATION
${PROJECT_SOURCES})
target_link_libraries(Cash PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
set_target_properties(Cash PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
install(TARGETS Cash
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(Cash)
endif()
使用 qmake 就没问题, 请问要怎么解决啊?? |