fix: adapt checkbox state handling for Qt6 - #775
Open
18202781743 wants to merge 1 commit into
Open
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe PR fixes Qt6 checkbox handling by adopting the checkStateChanged(Qt::CheckState) signature, replacing the invalid duplex string connection with a typed lambda connection, and retaining Qt5-specific behavior through conditional compilation. Sequence diagram for Qt6 checkbox state handlingsequenceDiagram
participant CheckBox as QCheckBox
participant Preview as DPrintPreviewDialogPrivate
participant SettingsOption as DSettingsOption
CheckBox->>Preview: checkStateChanged(Qt::CheckState)
Preview->>Preview: _q_checkStateChanged(int(state))
CheckBox->>Preview: checkStateChanged(Qt::CheckState)
Preview->>Preview: status == Qt::Unchecked
CheckBox->>SettingsOption: checkStateChanged(Qt::CheckState)
SettingsOption->>SettingsOption: setValue(status == Qt::Checked)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/widgets/dsettingswidgetfactory.cpp" line_range="278" />
<code_context>
option->connect(rightWidget, &QCheckBox::stateChanged,
#endif
- option, [ = ](int status) {
+ option, [ = ](Qt::CheckState status) {
option->setValue(status == Qt::Checked);
});
</code_context>
<issue_to_address>
**issue (bug_risk):** The Qt5 branch still connects `QCheckBox::stateChanged(int)`, but the lambda now requires `Qt::CheckState`; the new-style connection is type-incompatible and the Qt5 build fails to compile.
**Triggers:** When building with Qt5, where `QCheckBox::stateChanged` has the `int` parameter.
**Suggested fix:** Keep the lambda parameter as `int` in the Qt5 branch, or add a Qt-version-specific lambda so Qt5 receives `int` and Qt6 receives `Qt::CheckState`.
```suggestion
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
option, [ = ](Qt::CheckState status) {
#else
option, [ = ](int status) {
#endif
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
18202781743
force-pushed
the
fix-qt6-qcheckbox-checkStateChanged
branch
2 times, most recently
from
August 26, 2026 08:09
759c47e to
b474da1
Compare
1. Update sidebysideCheckBox signal lambda to use Qt::CheckState type in Qt6 builds 2. Replace deprecated SIGNAL/SLOT syntax for duplexCheckBox with member function pointer and lambda wrapping 3. Use Qt::Unchecked enum constant instead of numeric literal 0 for better readability 4. Simplify settings widget factory checkbox connection by using isChecked() instead of state parameter This change ensures compatibility with Qt6 where DCheckBox::checkStateChanged emits Qt::CheckState instead of int, preventing build failures and maintaining runtime behavior across Qt5/ Qt6. Log: Fixed Qt6 compatibility issues with checkbox state handling in print preview dialog Influence: 1. Test print preview dialog page setup options in Qt6 builds 2. Verify side-by-side printing checkbox toggles sequential print option correctly 3. Test duplex printing checkbox state changes trigger margin settings update 4. Verify check/uncheck state transitions work in both Qt5 and Qt6 5. Test settings widget checkbox option updates value correctly on toggle 6. Regression test all printer-related UI controls in preview dialog fix: 适配预览对话框中的Qt6 DCheckBox API变更 1. 更新sidebysideCheckBox信号lambda以在Qt6构建中使用Qt::CheckState类型 2. 将duplexCheckBox的废弃SIGNAL/SLOT语法替换为成员函数指针配合lambda封装 3. 使用Qt::Unchecked枚举常量替代数字字面量0以提高代码可读性 4. 简化设置控件工厂的复选框连接,改用isChecked()替代状态参数 此变更确保Qt6兼容性,因为Qt6中DCheckBox::checkStateChanged发出 Qt::CheckState而非int,避免构建失败并在Qt5/Qt6间维持运行行为。 Log: 修复打印预览对话框中复选框状态处理的Qt6兼容性问题 Influence: 1. 在Qt6构建中测试打印预览对话框页面设置选项 2. 验证并排打印复选框切换顺序打印选项功能正常 3. 测试双面打印复选框状态变化触发页边距设置更新 4. 在Qt5和Qt6中验证选中/取消选中状态转换 5. 测试设置控件复选框选项切换时正确更新值 6. 回归测试预览对话框中所有与打印机相关的UI控件
18202781743
force-pushed
the
fix-qt6-qcheckbox-checkStateChanged
branch
from
August 26, 2026 08:46
b474da1 to
918cf5a
Compare
BLumia
approved these changes
Aug 26, 2026
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Qt6 中
QCheckBox的复选状态信号签名由stateChanged(int)变为checkStateChanged(Qt::CheckState)。dtkwidget 中仍有 3 处 Qt6 分支使用旧式int参数:dprintpreviewdialog.cppduplex 复选框使用字符串式SIGNAL(checkStateChanged(int)),在 Qt6 下匹配不到信号,产生QObject::connect: No such signal QCheckBox::checkStateChanged(int)警告且连接静默失败。dprintpreviewdialog.cppsidebyside 复选框 lambda 参数为int,status == 0魔法数字。dsettingswidgetfactory.cpp复选框工厂 lambda 参数为int。本次统一改为 Qt6 正确的
Qt::CheckState类型,并将 duplex 的字符串式连接改为函数指针 lambda 连接。Changes
dprintpreviewdialog.cpp: duplex 复选框改为&DCheckBox::checkStateChanged+ lambda(显式int(state)转换传给_q_checkStateChanged);sidebyside 复选框参数改Qt::CheckState,status == 0改为status == Qt::Unchecked。dsettingswidgetfactory.cpp: 复选框工厂 lambda 参数改为Qt::CheckState。Qt5 分支(
stateChanged(int))保持不变。已用 Qt6 构建验证(dtk6widget100% 编译通过,无新增告警)。Test
No such signal警告DSettingsOptionSummary by Sourcery
Correct checkbox state handling across Qt6 widget integrations while maintaining Qt5 compatibility.
Bug Fixes:
Enhancements: