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


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

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


在下文中一共展示了QAbstractItemView::sizeHintForRow方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: showPopup

void QGraphicsCompleter::showPopup(const QRect& rect)
{
    Qt::LayoutDirection dir = Qt::LeftToRight;
    const int maxVisibleItems = 7;
    QPointF pos;
    int rh, w;

    const QRect screen = p_proxyPopup->scene()->views().at(0)->viewport()->geometry();
    QAbstractItemView *popup = static_cast<QAbstractItemView *>(p_proxyPopup->widget());

    int h = (popup->sizeHintForRow(0) * qMin(maxVisibleItems, popup->model()->rowCount()) + 3) + 3;
    QScrollBar *hsb = popup->horizontalScrollBar();
    if (hsb && hsb->isVisible())
        h += popup->horizontalScrollBar()->sizeHint().height();

    if (rect.isValid()) {
        rh = rect.height();
        w = rect.width();
        pos = rect.bottomLeft();
    } else {
        rh = graphicsItem()->boundingRect().height();
        pos = graphicsItem()->mapRectToScene(
                graphicsItem()->boundingRect()).bottomLeft();
        w = popup->width();
    }

    if (w > screen.width())
        w = screen.width();
    if ((pos.x() + w) > (screen.x() + screen.width()))
        pos.setX(screen.x() + screen.width() - w);
    if (pos.x() < screen.x())
        pos.setX(screen.x());

    int top = pos.y() - rh - screen.top() + 2;
    int bottom = screen.bottom() - pos.y();
    h = qMax(h, popup->minimumHeight());
    if (h > bottom) {
        h = qMin(qMax(top, bottom), h);

        if (top > bottom)
            pos.setY(pos.y() - h - rh+ 2);
    }

    popup->setGeometry(pos.x(), pos.y(), w, h+5);
    p_proxyPopup->update();

    if (!p_proxyPopup->isVisible())
        p_proxyPopup->show();

}
开发者ID:,项目名称:,代码行数:50,代码来源:

示例3: setupMenu

void ToolbarSearch::setupMenu()
{
    if (m_suggestions.isEmpty()
            || (m_model->rowCount() > 0
                && m_model->item(0) != m_suggestionsItem)) {
        m_model->clear();
        m_suggestionsItem = 0;
    } else {
        m_model->removeRows(1, m_model->rowCount() -1 );
    }

    QFont boldFont;
    boldFont.setBold(true);
    if (!m_suggestions.isEmpty()) {
        if (m_model->rowCount() == 0) {
            if (!m_suggestionsItem) {
                m_suggestionsItem = new QStandardItem();
                m_suggestionsItem->setFont(boldFont);
                retranslate();
            }
            m_model->appendRow(m_suggestionsItem);
        }
        for (int i = 0; i < m_suggestions.count(); ++i) {
            const QString &text = m_suggestions.at(i);
            m_model->appendRow(new QStandardItem(text));
        }
    }

    if (m_recentSearches.isEmpty()) {
        m_recentSearchesItem = new QStandardItem(tr("No Recent Searches"));
        m_recentSearchesItem->setFont(boldFont);
        m_model->appendRow(m_recentSearchesItem);
    } else {
        m_recentSearchesItem = new QStandardItem(tr("Recent Searches"));
        m_recentSearchesItem->setFont(boldFont);
        m_model->appendRow(m_recentSearchesItem);
        for (int i = 0; i < m_recentSearches.count(); ++i) {
            QString text = m_recentSearches.at(i);
            m_model->appendRow(new QStandardItem(text));
        }
    }

    QAbstractItemView *view = completer()->popup();
    view->setFixedHeight(view->sizeHintForRow(0) * m_model->rowCount() + view->frameWidth() * 2);
}
开发者ID:porphyr,项目名称:arora,代码行数:45,代码来源:toolbarsearch.cpp


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