Skip to content

feat: support Qt 6.10#687

Merged
ComixHe merged 1 commit intolinuxdeepin:masterfrom
ComixHe:master
Oct 13, 2025
Merged

feat: support Qt 6.10#687
ComixHe merged 1 commit intolinuxdeepin:masterfrom
ComixHe:master

Conversation

@ComixHe
Copy link
Contributor

@ComixHe ComixHe commented Oct 13, 2025

No description provided.

deepin-ci-robot added a commit to linuxdeepin/dtk6widget that referenced this pull request Oct 13, 2025
Synchronize source files from linuxdeepin/dtkwidget.

Source-pull-request: linuxdeepin/dtkwidget#687
@github-actions
Copy link
Contributor

github-actions bot commented Oct 13, 2025

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

Signed-off-by: ComixHe <heyuming@deepin.org>
deepin-ci-robot added a commit to linuxdeepin/dtk6widget that referenced this pull request Oct 13, 2025
Synchronize source files from linuxdeepin/dtkwidget.

Source-pull-request: linuxdeepin/dtkwidget#687
@deepin-ci-robot
Copy link
Contributor

deepin pr auto review

我对这段CMake代码进行审查,提出以下改进意见:

  1. 代码逻辑和语法:
  • 代码整体语法正确,逻辑清晰
  • 版本判断使用了STREQUAL和VERSION_GREATER_EQUAL,这是合适的做法
  • 错误处理使用了FATAL_ERROR,这是适当的
  1. 代码质量:
  • 使用了明确的变量名(QT_VERSION_MAJOR, Qt6Core_VERSION),提高了可读性
  • 使用了GLOB来收集头文件,这是CMake的常见做法
  1. 性能考虑:
  • GLOB操作在配置时执行一次,不会影响构建性能
  • 版本检查在配置时进行,不会影响运行时性能
  1. 安全性:
  • 错误处理完善,对不支持的Qt版本会报错
  • 变量使用明确,避免了潜在的命名冲突

改进建议:

  1. 变量作用域优化:
if("${QT_VERSION_MAJOR}" STREQUAL "5")
    find_package(Qt5 REQUIRED COMPONENTS X11Extras)
elseif("${QT_VERSION_MAJOR}" STREQUAL "6")
    if (${Qt6Core_VERSION} VERSION_GREATER_EQUAL "6.10.0")
      set(QT_NO_PRIVATE_MODULE_WARNING ON)
      find_package(Qt6 REQUIRED COMPONENTS GuiPrivate WidgetsPrivate PrintSupportPrivate)
    endif()
else()
    message(FATAL_ERROR "Unsupported Qt Version: ${QT_VERSION_MAJOR}")
endif()

建议将QT_NO_PRIVATE_MODULE_WARNING的作用域限制在if块内:

if("${QT_VERSION_MAJOR}" STREQUAL "5")
    find_package(Qt5 REQUIRED COMPONENTS X11Extras)
elseif("${QT_VERSION_MAJOR}" STREQUAL "6")
    if (${Qt6Core_VERSION} VERSION_GREATER_EQUAL "6.10.0")
      set(QT_NO_PRIVATE_MODULE_WARNING ON PARENT_SCOPE)
      find_package(Qt6 REQUIRED COMPONENTS GuiPrivate WidgetsPrivate PrintSupportPrivate)
    endif()
else()
    message(FATAL_ERROR "Unsupported Qt Version: ${QT_VERSION_MAJOR}")
endif()
  1. 版本检查的健壮性:
    建议添加更详细的版本检查信息:
if("${QT_VERSION_MAJOR}" STREQUAL "5")
    find_package(Qt5 REQUIRED COMPONENTS X11Extras)
    message(STATUS "Found Qt5 version: ${Qt5Core_VERSION}")
elseif("${QT_VERSION_MAJOR}" STREQUAL "6")
    if(${Qt6Core_VERSION} VERSION_LESS "6.10.0")
        message(WARNING "Qt6 version ${Qt6Core_VERSION} is below recommended version 6.10.0")
    endif()
    set(QT_NO_PRIVATE_MODULE_WARNING ON PARENT_SCOPE)
    find_package(Qt6 REQUIRED COMPONENTS GuiPrivate WidgetsPrivate PrintSupportPrivate)
    message(STATUS "Found Qt6 version: ${Qt6Core_VERSION}")
else()
    message(FATAL_ERROR "Unsupported Qt Version: ${QT_VERSION_MAJOR}. Only Qt5 and Qt6 are supported.")
endif()
  1. 添加更多的错误处理:
if("${QT_VERSION_MAJOR}" STREQUAL "5")
    find_package(Qt5 REQUIRED COMPONENTS X11Extras)
    if(NOT Qt5_FOUND)
        message(FATAL_ERROR "Failed to find required Qt5 components")
    endif()
elseif("${QT_VERSION_MAJOR}" STREQUAL "6")
    if(${Qt6Core_VERSION} VERSION_GREATER_EQUAL "6.10.0")
        set(QT_NO_PRIVATE_MODULE_WARNING ON PARENT_SCOPE)
        find_package(Qt6 REQUIRED COMPONENTS GuiPrivate WidgetsPrivate PrintSupportPrivate)
        if(NOT Qt6_FOUND)
            message(FATAL_ERROR "Failed to find required Qt6 components")
        endif()
    else()
        message(WARNING "Qt6 private modules require version 6.10.0 or higher")
    endif()
else()
    message(FATAL_ERROR "Unsupported Qt Version: ${QT_VERSION_MAJOR}. Only Qt5 and Qt6 are supported.")
endif()

这些改进将使代码更加健壮、可维护,并提供更好的错误处理和反馈。

@ComixHe ComixHe requested a review from 18202781743 October 13, 2025 06:10
@deepin-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, ComixHe

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ComixHe ComixHe merged commit 93b3065 into linuxdeepin:master Oct 13, 2025
22 of 23 checks passed
ComixHe pushed a commit to linuxdeepin/dtk6widget that referenced this pull request Oct 13, 2025
Synchronize source files from linuxdeepin/dtkwidget.

Source-pull-request: linuxdeepin/dtkwidget#687
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants