本文整理汇总了C++中QAbstractScrollArea::size方法的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractScrollArea::size方法的具体用法?C++ QAbstractScrollArea::size怎么用?C++ QAbstractScrollArea::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAbstractScrollArea
的用法示例。
在下文中一共展示了QAbstractScrollArea::size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: find
void FindBar::find(FindBar::FindDirection dir)
{
Q_ASSERT(m_associatedWebView);
if (isHidden()) {
QPoint previous_position = m_associatedWebView->page()->currentFrame()->scrollPosition();
m_associatedWebView->page()->focusNextPrevChild(true);
m_associatedWebView->page()->currentFrame()->setScrollPosition(previous_position);
return;
}
QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument;
if (dir == Backward)
options |= QWebPage::FindBackward;
if (matchCase())
options |= QWebPage::FindCaseSensitively;
// HACK Because we're using the QWebView inside a QScrollArea container, the attempts
// to scroll the QWebView itself have no direct effect.
// Therefore we temporarily shrink the page viewport to the message viewport (ie. the size it
// can cover at max), then perform the search, store the scrollPosition, restore the page viewport
// and finally scroll the messageview to the gathered scrollPosition, mapped to the message (ie.
// usually offset by the mail header)
auto emb = qobject_cast<EmbeddedWebView *>(m_associatedWebView);
QAbstractScrollArea *container = emb ? static_cast<QAbstractScrollArea*>(emb->scrollParent()) : nullptr;
const QSize oldVpS = m_associatedWebView->page()->viewportSize();
const bool useResizeTrick = container ? !!container->verticalScrollBar() : false;
// first shrink the page viewport
if (useResizeTrick) {
m_associatedWebView->setUpdatesEnabled(false); // don't let the user see the flicker we might produce
QSize newVpS = oldVpS.boundedTo(container->size());
m_associatedWebView->page()->setViewportSize(newVpS);
}
// now perform the search (pot. in the shrinked viewport)
bool found = m_associatedWebView->page()->findText(_lastStringSearched, options);
notifyMatch(found);
// scroll and reset the page viewport if necessary
if (useResizeTrick) {
Q_ASSERT(container->verticalScrollBar());
// the page has now a usable scroll position ...
int scrollPosition = m_associatedWebView->page()->currentFrame()->scrollPosition().y();
// ... which needs to be extended by the pages offset (usually the header widget)
// NOTICE: QWidget::mapTo() fails as the viewport child position can be negative, so we run ourself
QWidget *runner = m_associatedWebView;
while (runner->parentWidget() != container->viewport()) {
scrollPosition += runner->y();
runner = runner->parentWidget();
}
// reset viewport to original size ...
m_associatedWebView->page()->setViewportSize(oldVpS);
// ... let the user see the change ...
m_associatedWebView->setUpdatesEnabled(true);
// ... and finally scroll to the desired position
if (found)
container->verticalScrollBar()->setValue(scrollPosition);
}
if (!found) {
QPoint previous_position = m_associatedWebView->page()->currentFrame()->scrollPosition();
m_associatedWebView->page()->focusNextPrevChild(true);
m_associatedWebView->page()->currentFrame()->setScrollPosition(previous_position);
}
}