fix: Update signal connections for compatibility with Qt 6#229
Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom Dec 30, 2025
Merged
fix: Update signal connections for compatibility with Qt 6#229deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
Conversation
- Refactored signal-slot connections in ColorWidgetAction.cpp to use modern syntax for Qt 6 compatibility. - Maintained backward compatibility with Qt versions prior to 6.0.0. This change improves code clarity and ensures proper functionality across different Qt versions. bug: https://pms.uniontech.com/bug-view-304093.html
35ea10e to
e5ff53e
Compare
deepin pr auto review我来帮你审查这段代码的修改。这是一个关于Qt版本兼容性修改的diff,主要涉及信号槽连接方式的更新。让我从几个方面来分析:
改进建议:
void ColorWidgetAction::initWidget(DWidget *pParent)
{
// ... 其他代码保持不变 ...
for (int iLoop = 0; iLoop < colorlst.size(); ++iLoop) {
// ... 按钮创建代码保持不变 ...
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
connect(btn, SIGNAL(clicked()), sigMap, SLOT(map()));
sigMap->setMapping(btn, iLoop);
#else
connect(btn, &RoundColorWidget::clicked, this, [this, iLoop]() {
slotBtnClicked(iLoop);
});
#endif
buttonLayout->addWidget(btn);
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
connect(sigMap, SIGNAL(mapped(int)), SLOT(slotBtnClicked(int)));
#endif
}
void ColorWidgetAction::connectColorButton(RoundColorWidget* btn, int index)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
connect(btn, SIGNAL(clicked()), sigMap, SLOT(map()));
sigMap->setMapping(btn, index);
#else
connect(btn, &RoundColorWidget::clicked, this, [this, index]() {
slotBtnClicked(index);
});
#endif
}
// qCDebug(appLog) << "Color widget initialization completed";
// 这个日志在循环中会打印多次,可能不是必要的总的来说,这个修改是合理的,主要目的是为了适配Qt6的新特性。代码质量良好,但可以通过一些小的重构来提高可维护性。 |
lzwind
approved these changes
Dec 30, 2025
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dengzhongyuan365-dev, lzwind 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 |
Contributor
Author
|
/forcemerge |
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.
This change improves code clarity and ensures proper functionality across different Qt versions.
bug: https://pms.uniontech.com/bug-view-304093.html