QT中实现页面滚动下页面后有些字不能完全显示(最顶条目录,和最低层目录),怎么调试对齐

fiystream 2011-01-17 03:42:58
void InformationList::roll_to_current_page()
{
float average_value;
float upper_limit_value;
float lower_limit_value;
float current_offset;
float distance_value;

InformationListItem *p_first_item = (InformationListItem *)(contentsLayout->itemAt(0));
InformationListItem *p_last_item = (InformationListItem *)(contentsLayout->itemAt(contentsLayout->count()-1));
InformationListItem *p_four_item = (InformationListItem *)(contentsLayout->itemAt(3));
InformationListItem *p_current_item = (InformationListItem *)(contentsLayout->itemAt(m_old_index));

average_value = ((p_last_item->y()) - (p_first_item->y())) / (contentsLayout->count()-1);
upper_limit_value = p_first_item->y();
lower_limit_value = p_four_item->y();

if (m_old_index >= 0 && m_old_index <= 3)
{
current_offset = m_pScroll->offset();
m_pScroll->setOffset(current_offset - (contentsLayout->count())*average_value);
}
else if (m_old_index >= (contentsLayout->count() - 4) && m_old_index <= (contentsLayout->count() - 1))
{
current_offset = m_pScroll->offset();
m_pScroll->setOffset(current_offset + (contentsLayout->count())*average_value);
}
else
{
current_offset = m_pScroll->offset();

if ((p_current_item->y() - current_offset) > lower_limit_value)
{
m_pScroll->setOffset(current_offset + (p_current_item->y() - current_offset - lower_limit_value) + average_value*3);
}

if ((p_current_item->y() - current_offset) < upper_limit_value)
{
m_pScroll->setOffset(current_offset - ((-1)*(p_current_item->y() - current_offset - upper_limit_value)));
}
}
}
...全文
131 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

16,238

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧