本文整理汇总了C++中QScrollArea::ensureWidgetVisible方法的典型用法代码示例。如果您正苦于以下问题:C++ QScrollArea::ensureWidgetVisible方法的具体用法?C++ QScrollArea::ensureWidgetVisible怎么用?C++ QScrollArea::ensureWidgetVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScrollArea
的用法示例。
在下文中一共展示了QScrollArea::ensureWidgetVisible方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QVERIFY
void tst_QScrollArea::ensureMicroFocusVisible_Task_167838()
{
QScrollArea scrollArea;
scrollArea.resize(100, 100);
scrollArea.show();
QWidget *parent = new QWidget;
parent->setLayout(new QVBoxLayout);
QWidget *child = new WidgetWithMicroFocus;
parent->layout()->addWidget(child);
parent->resize(300, 300);
scrollArea.setWidget(parent);
scrollArea.ensureWidgetVisible(child, 10, 10);
QRect microFocus = child->inputMethodQuery(Qt::ImMicroFocus).toRect();
QPoint p = child->mapTo(scrollArea.viewport(), microFocus.topLeft());
microFocus.translate(p - microFocus.topLeft());
QVERIFY(scrollArea.viewport()->rect().contains(microFocus));
}
示例2: setExpanded
void RolloutBox::setExpanded(bool expanded) {
if (m_expanded != expanded) {
QScrollArea *sa = 0;
QWidget *p = parentWidget();
while (p) {
sa = qobject_cast<QScrollArea*>(p);
if (sa) break;
p = p->parentWidget();
}
bool areUpdatesEnabled;
if (sa) {
areUpdatesEnabled = updatesEnabled();
sa->setUpdatesEnabled(false);
}
m_expanded = !m_expanded;
QList<QWidget*> L = findChildren<QWidget*>();
for (int i = 0; i < L.size(); ++i) {
if ((L[i] != m_toolButton) && (L[i] != m_checkBox)) L[i]->setVisible(m_expanded);
}
parentWidget()->updateGeometry();
if (sa) {
qApp->processEvents();
if (m_expanded) sa->ensureWidgetVisible(this);
sa->setUpdatesEnabled(true);
}
if (m_toolButton) {
m_toolButton->setArrowType(m_expanded? Qt::DownArrow : Qt::RightArrow);
}
toggled(m_expanded);
}
}