本文整理汇总了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];
}
}
示例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);
}