fix: replece resize to setFixedSize#512
Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom Mar 4, 2026
Merged
Conversation
to fixed size,please used setFixedSize PMS: BUG-351725
deepin pr auto review针对这段 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
改进后的代码示例综合考虑可读性和逻辑安全性,建议重构如下: // 在类定义中或头文件顶部定义常量
static constexpr int kExtraTopPadding = 20; // 对应原代码的 20
static constexpr int kButtonSpacing = 10; // 对应原代码的 10
public Q_SLOTS:
void updateHeight(int h) {
// 安全检查:确保关键指针有效
if (!m_netView || !m_mainLayout || !m_netSetBtn || !m_netCheckBtn) {
return;
}
m_netView->setMaxHeight(h);
if (m_netView->height() > h) {
m_netView->setFixedHeight(h);
}
// 计算基础高度:视图高度 + 顶部额外间距 + 布局边距
int baseHeight = m_netView->height() + kExtraTopPadding + m_mainLayout->contentsMargins().top();
// 计算按钮区域的高度
int buttonsHeight = 0;
if (m_netCheckBtn->isVisibleTo(this)) {
buttonsHeight = m_netSetBtn->height() + m_netCheckBtn->height() + kButtonSpacing;
} else {
buttonsHeight = m_netSetBtn->height();
}
// 计算最终目标高度
int finalHeight = qMax(m_minHeight, baseHeight + buttonsHeight);
// 根据实际需求选择设置大小的方式
// 方案 A: 允许布局调整(推荐用于子控件)
resize(m_netView->width(), finalHeight);
// 方案 B: 强制固定大小(仅用于需要完全锁定的弹窗等)
// setFixedSize(m_netView->width(), finalHeight);
}总结
|
caixr23
approved these changes
Mar 4, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: caixr23, ut003640 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
|
/merge |
Contributor
|
This pr cannot be merged! (status: unstable) |
Contributor
Author
|
/forcemerge |
Contributor
|
This pr force merged! (status: unstable) |
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.
to fixed size,please used setFixedSize
PMS: BUG-351725