Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于布局 #1

Open
Mingzhe-Zhu opened this issue Dec 12, 2017 · 0 comments
Open

关于布局 #1

Mingzhe-Zhu opened this issue Dec 12, 2017 · 0 comments

Comments

@Mingzhe-Zhu
Copy link

看了下你的代码,控件布局部分没有用layout,都是用moveto(比如主界面的几个控件)、或者QPainter(对于比如体检得分控件),个人理解本质上依然是绝对布局。
比如void MainTopWidget::updateSizeAndPos()

{
m_userWidget->move(0, m_titleWidget->y() + m_titleWidget->height() + 10);
m_scoreWidget->move(0, m_userWidget->y() + m_userWidget->height() + 10);
m_bottomWidget->move(0, m_scoreWidget->y() + m_scoreWidget->height() + 10);
}
是不是这样写更好写:
QVBoxLayout* vLayout = new QVBoxLayout;
QHBoxLayout* hLayout = new QHBoxLayout;
hLayout->addStretch();
hLayout->addWidget(m_userWidget);
QHBoxLayout* hLayout _1= new QHBoxLayout;
hLayout_1->addWidget(m_scoreWidget);
hLayout_1->addStretch();
vLayout->addLayout(hLayout);
vLayout->addLayout(hLayout_1);
vLayout->addWidget(m_bottomWidget);

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

No branches or pull requests

1 participant