本文整理汇总了C++中QAbstractItemView::width方法的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractItemView::width方法的具体用法?C++ QAbstractItemView::width怎么用?C++ QAbstractItemView::width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAbstractItemView
的用法示例。
在下文中一共展示了QAbstractItemView::width方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: moveGrip
void tst_QColumnView::moveGrip()
{
QFETCH(bool, reverse);
if (reverse)
qApp->setLayoutDirection(Qt::RightToLeft);
ColumnView view;
TreeModel model;
view.setModel(&model);
QModelIndex home = model.thirdLevel();
view.setCurrentIndex(home);
view.resize(640, 200);
view.show();
QTest::qWait(ANIMATION_DELAY);
int columnNum = view.createdColumns.count() - 2;
QVERIFY(columnNum >= 0);
QObjectList list = view.createdColumns[columnNum]->children();
QColumnViewGrip *grip = 0;
for (int i = 0; i < list.count(); ++i) {
if ((grip = qobject_cast<QColumnViewGrip *>(list[i]))) {
break;
}
}
if (!grip)
return;
QAbstractItemView *column = qobject_cast<QAbstractItemView *>(grip->parent());
int oldX = column->width();
QCOMPARE(view.columnWidths()[columnNum], oldX);
grip->moveGrip(10);
QCOMPARE(view.columnWidths()[columnNum], (oldX + (reverse ? -10 : 10)));
}
示例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();
}