当前位置: 首页>>代码示例>>C++>>正文


C++ QAbstractItemView::sizeHintForColumn方法代码示例

本文整理汇总了C++中QAbstractItemView::sizeHintForColumn方法的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractItemView::sizeHintForColumn方法的具体用法?C++ QAbstractItemView::sizeHintForColumn怎么用?C++ QAbstractItemView::sizeHintForColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QAbstractItemView的用法示例。


在下文中一共展示了QAbstractItemView::sizeHintForColumn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cacheSectionMinSizes

void RDHeaderView::cacheSectionMinSizes()
{
  m_sectionMinSizes.resize(count());
  m_sectionMinSizesTotal = 0;

  for(int i = 0; i < m_sectionMinSizes.count(); i++)
  {
    int sz = 0;

    // see if we can fetch the column/row size hint from the item view
    QAbstractItemView *view = qobject_cast<QAbstractItemView *>(parent());
    if(view)
    {
      if(orientation() == Qt::Horizontal)
        sz = view->sizeHintForColumn(i);
      else
        sz = view->sizeHintForRow(i);
    }

    // also include the size for the header as another minimum
    if(orientation() == Qt::Horizontal)
      sz = qMax(sz, sectionSizeFromContents(i).width());
    else
      sz = qMax(sz, sectionSizeFromContents(i).height());

    // finally respect the minimum section size specified
    sz = qMax(sz, minimumSectionSize());

    // update the minimum size for this section and count the total which we'll need
    m_sectionMinSizes[i] = sz;
    m_sectionMinSizesTotal += m_sectionMinSizes[i];
  }
}
开发者ID:silvesthu,项目名称:renderdoc,代码行数:33,代码来源:RDHeaderView.cpp

示例2: sltAdjustTreeWidget

void UIHostNetworkManagerWidget::sltAdjustTreeWidget()
{
    /* Get the tree-widget abstract interface: */
    QAbstractItemView *pItemView = m_pTreeWidget;
    /* Get the tree-widget header-view: */
    QHeaderView *pItemHeader = m_pTreeWidget->header();

    /* Calculate the total tree-widget width: */
    const int iTotal = m_pTreeWidget->viewport()->width();
    /* Look for a minimum width hints for non-important columns: */
    const int iMinWidth1 = qMax(pItemView->sizeHintForColumn(Column_IPv4), pItemHeader->sectionSizeHint(Column_IPv4));
    const int iMinWidth2 = qMax(pItemView->sizeHintForColumn(Column_IPv6), pItemHeader->sectionSizeHint(Column_IPv6));
    const int iMinWidth3 = qMax(pItemView->sizeHintForColumn(Column_DHCP), pItemHeader->sectionSizeHint(Column_DHCP));
    /* Propose suitable width hints for non-important columns: */
    const int iWidth1 = iMinWidth1 < iTotal / Column_Max ? iMinWidth1 : iTotal / Column_Max;
    const int iWidth2 = iMinWidth2 < iTotal / Column_Max ? iMinWidth2 : iTotal / Column_Max;
    const int iWidth3 = iMinWidth3 < iTotal / Column_Max ? iMinWidth3 : iTotal / Column_Max;
    /* Apply the proposal: */
    m_pTreeWidget->setColumnWidth(Column_IPv4, iWidth1);
    m_pTreeWidget->setColumnWidth(Column_IPv6, iWidth2);
    m_pTreeWidget->setColumnWidth(Column_DHCP, iWidth3);
    m_pTreeWidget->setColumnWidth(Column_Name, iTotal - iWidth1 - iWidth2 - iWidth3);
}
开发者ID:mdaniel,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:23,代码来源:UIHostNetworkManager.cpp


注:本文中的QAbstractItemView::sizeHintForColumn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。