本文整理汇总了C++中QWebFrame::setScrollPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebFrame::setScrollPosition方法的具体用法?C++ QWebFrame::setScrollPosition怎么用?C++ QWebFrame::setScrollPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebFrame
的用法示例。
在下文中一共展示了QWebFrame::setScrollPosition方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setScrollPosition
void QWebFrameProto::setScrollPosition(const QPoint & pos)
{
scriptDeprecated("QWebFrame will not be available in future versions");
QWebFrame *item = qscriptvalue_cast<QWebFrame*>(thisObject());
if (item)
item->setScrollPosition(pos);
}
示例2: sendMouseEvent
bool SessionTab::sendMouseEvent(QMouseEvent::Type type, const QPoint& point, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
{
QWebFrame* frame = webPage->mainFrame();
QPoint relativePoint;
unsigned int scrollX = 0;
unsigned int scrollY = 0;
QPoint savedScrollPos = frame->scrollPosition();
unsigned int w = frame->geometry().width() - frame->scrollBarGeometry(Qt::Vertical).width();
unsigned int h = frame->geometry().height() - frame->scrollBarGeometry(Qt::Horizontal).height();
// unsigned int maxScrollX = frame->scrollBarMaximum(Qt::Horizontal);
// unsigned int maxScrollY = frame->scrollBarMaximum(Qt::Vertical);
if (point.x() > (w - 1)) {
scrollX = point.x() - w + 1;
relativePoint.setX(w - 1);
} else {
relativePoint.setX(point.x());
}
if (point.y() > (h - 1)) {
scrollY = point.y() - h + 1;
relativePoint.setY(h - 1);
} else {
relativePoint.setY(point.y());
}
QMouseEvent event(type, relativePoint, button, buttons, modifiers);
frame->setScrollPosition(QPoint(scrollX, scrollY));
bool ret = sendEvent(&event);
qDebug() << "Mouse event" << type << relativePoint;
frame->setScrollPosition(savedScrollPos);
return ret;
}
示例3:
void
message_view::page_down()
{
QWebFrame* frame = m_bodyv->page()->mainFrame();
if (!frame)
return;
QPoint pos = frame->scrollPosition();
int y = m_bodyv->geometry().height() + pos.y();
if (y > frame->contentsSize().height()-frame->geometry().height())
y = frame->contentsSize().height()-frame->geometry().height();
pos.setY(y);
frame->setScrollPosition(pos);
}
示例4: handleAutoscroll
void CustomWebView::handleAutoscroll ()
{
if (!ScrollDelta_)
return;
AccumulatedScrollShift_ += ScrollDelta_;
if (std::abs (AccumulatedScrollShift_) >= 1)
{
QWebFrame *mf = page ()->mainFrame ();
QPoint pos = mf->scrollPosition ();
pos += QPoint (0, AccumulatedScrollShift_);
mf->setScrollPosition (pos);
AccumulatedScrollShift_ -= static_cast<int> (AccumulatedScrollShift_);
}
}
示例5: scrollWidget
// scroll by dx, dy
// return true if the widget was scrolled
bool scrollWidget(const int dx, const int dy)
{
QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(widget);
if (scrollArea) {
const int x = scrollArea->horizontalScrollBar()->value();
const int y = scrollArea->verticalScrollBar()->value();
scrollArea->horizontalScrollBar()->setValue(x - dx);
scrollArea->verticalScrollBar()->setValue(y - dy);
return (scrollArea->horizontalScrollBar()->value() != x
|| scrollArea->verticalScrollBar()->value() != y);
}
QWebView *webView = qobject_cast<QWebView*>(widget);
if (webView) {
QWebFrame *frame = webView->page()->mainFrame();
const QPoint position = frame->scrollPosition();
frame->setScrollPosition(position - QPoint(dx, dy));
return frame->scrollPosition() != position;
}
return false;
}
示例6: handleLoadFinished
void WebTabPanel::handleLoadFinished(bool) {
QWebFrame *frame = web->page()->mainFrame();
QString url=frame->url().toString();
//QMessageBox::information (0,"assdf",tr("Handle load finished, state: ")+QString::number(state)+tr(", url: ")+frame->url().toString());
infoArea->hide();
progress->hide();
loadingText->hide();
if (url=="http://twitter.com/login") {
if (!tweets->getAuthenticatingFetcher()) {
state=-1;
return;
}
QString user = tweets->getAuthenticatingFetcher()->getUsername();
QString pass = tweets->getAuthenticatingFetcher()->getPassword();
// Homepage login
//frame->evaluateJavaScript(tr("var f=document.getElementById('signin');document.getElementById('username').value=\"")+user+tr("\";document.getElementById('password').value=\"")+pass+tr("\";f.submit();"));
// redirect page login
loadingText->setText("Please wait, signing in to twitter...");
frame->evaluateJavaScript(tr("var f=document.forms[1];f['username_or_email'].value=\"")+user+tr("\";f['session[password]'].value=\"")+pass+tr("\";f.submit();"));
state=1;//loggin in
} else if (url=="http://twitter.com/invitations/find_on_twitter") {
// Now at being passed to twitter state
state=2;//Searching
web->show();
frame->evaluateJavaScript(tr("function $(s){return document.getElementById(s);}function __yasstlinks() {var i=['home_link','profile_link','settings_link','help_link','sign_out_link'];for (var b in i) {b=$(i[b]);b.style.display='none';}i=$('footer').firstChild.nextSibling.nextSibling.nextSibling.firstChild.nextSibling;while(i.nextSibling){i.parentNode.removeChild(i.nextSibling);}}__yasstlinks();"));
frame->setScrollPosition(QPoint(0,0));
//QTimer::singleShot(1000,this,SLOT(resetScroll()));
web->setEnabled(true);
handleTimeout();
} else if (url.startsWith(tr("http://twitter.com/"))) {
state=3;//Search results or user info.
frame->evaluateJavaScript(tr("function $(s){return document.getElementById(s);}function __yasstlinks() {var i=['home_link','profile_link','settings_link','help_link','sign_out_link'];for (var b in i) {b=$(i[b]);b.style.display='none';}i=$('footer').firstChild.nextSibling.nextSibling.nextSibling.firstChild.nextSibling;while(i.nextSibling){i.parentNode.removeChild(i.nextSibling);}}__yasstlinks();"));
frame->evaluateJavaScript(tr("function __yasst() {i=$('timeline');i.innerHTML='<style>.follow-actions input{display:none;} a.__yasst-followsingle {text-decoration:none; visibility:visible !important; -webkit-appearance: none; -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -webkit-box-align: center; -webkit-box-sizing: border-box; -webkit-rtl-ordering: logical; -webkit-user-select: text; background-color: rgb(230, 230, 230); border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; color: black; cursor: pointer; display: inline-block; font-family: \\'Lucida Grande\\'; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; height: 23px; letter-spacing: normal; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 8px; padding-right: 8px; padding-top: 4px; text-align: center; text-indent: 0px; text-shadow: none; text-transform: none; vertical-align: top; white-space: pre; width: 48px; word-spacing: 0px;} a:hover.__yasst-follow,a:hover.__yasst-followsingle{background-color: rgb(204, 204, 204);} a.__yasst-follow{visibility: visible !important; -webkit-appearance: none; -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -webkit-box-align: center; -webkit-box-sizing: border-box; -webkit-rtl-ordering: logical; -webkit-user-select: text; background-color: rgb(230, 230, 230); border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; color: black; cursor: pointer; display: none; font-family: \\'Lucida Grande\\'; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; height: auto; letter-spacing: normal; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 8px; padding-right: 8px; padding-top: 4px; text-align: center; text-indent: 0px; text-shadow: none; text-transform: none; vertical-align: top; white-space: pre; width: 80px; word-spacing: 0px;}</style>'+$('timeline').innerHTML;var e=document.getElementById('follow_control');if (e!=null) {var u=e.parentNode.parentNode.className;u=u.substr(u.lastIndexOf(' ')+1);var l=document.createElement('div');l.innerHTML='<a class=\\\"__yasst-followsingle\\\" href=\\\"twitter:/follow/'+u+'\\\">Follow</a>';e.parentNode.parentNode.insertBefore(l,e.parentNode);} else { e=i.getElementsByClassName('follow-actions');for(b=0;b<e.length;b++) {var u=e[b].parentNode.parentNode.className;u=u.substr(u.lastIndexOf(' ')+6);var l=document.createElement('div');var c=e[b].childNodes;for(var x=0;x<c.length;x++) {if (c[x].nodeName=='FORM') {var d=c[x].action.substr(c[x].action.lastIndexOf('/')+1);var f=c[x].firstChild.childNodes;l.innerHTML='<a class=\\\"__yasst-follow\\\" href=\\\"twitter:/follow/'+u+'\\\">Follow</a>';for(var y=0;y<f.length;y++) {if(f[y].nodeName=='INPUT'&&f[y].type=='submit') {f[y].parentNode.insertBefore(l,f[y]);}}}}}}}__yasst();"));
web->setEnabled(true);
//frame->setScrollPosition(QPoint(0,0));
//QTimer::singleShot(1000,this,SLOT(resetScroll()));
}
}
示例7: scrollHome
void WebView::scrollHome()
{
QWebFrame* frame = this->page()->mainFrame();
frame->setScrollPosition(QPoint(0, 0));
}
示例8: scrollPageUp
void WebView::scrollPageUp()
{
QWebFrame* frame = this->page()->mainFrame();
QPoint point = frame->scrollPosition();
frame->setScrollPosition(point - QPoint(0, this->page()->mainFrame()->geometry().height()));
}
示例9: scrollUp
void WebView::scrollUp()
{
QWebFrame* frame = this->page()->mainFrame();
QPoint point = frame->scrollPosition();
frame->setScrollPosition(point - QPoint(0, 100));
}
示例10: scrollEnd
void WebView::scrollEnd()
{
QWebFrame* frame = this->page()->mainFrame();
frame->setScrollPosition(QPoint(0, frame->contentsSize().height()));
}
示例11: setScrollPosition
void setScrollPosition(const QPoint& point, const QPoint& /* overShootDelta */)
{
QWebFrame* frame = currentFrame();
if (frame)
frame->setScrollPosition(point);
}