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


C++ QWebView类代码示例

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


在下文中一共展示了QWebView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FindCloserContainer

bool MyWebView::eventFilter(QObject *watched, QEvent *event)
{
	if (!m_boolEnableEvtProcess) { return false; }

	if (event->type() == QEvent::MouseMove)
	{
		QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
		QWebView *view          = dynamic_cast<QWebView*>(watched);
		QPoint pos              = view->mapFromGlobal(mouseEvent->globalPos());
		QWebFrame *frame        = view->page()->frameAt(mouseEvent->pos());
		if (frame!=NULL)
		{
			QWebHitTestResult hitTestResult = frame->hitTestContent(pos);
			// if the hovered elem is not the same as the previously hovered
			if (hitTestResult.element() != m_old_hover_element)
			{
				QWebElement elemCurrent = hitTestResult.element();
				// if dragging, overwrite with closer WContainer
				if (m_boolIsDraggingWidget)
				{
					elemCurrent = FindCloserContainer(elemCurrent);
				}
				if (!elemCurrent.isNull())
				{
					// Change color
					ChangeHoveredElemColor(elemCurrent);
					// Message to print
					m_strCurrentElemId = elemCurrent.attribute("id");
					// Emit message
					QStringList strlistClasses = elemCurrent.classes();
					strlistClasses.removeAll(g_strHighlightClassName);
					Q_EMIT mouseMovedOverElem(m_strCurrentElemId, strlistClasses.join(' '));
				}
			}
		}
	}
	else if (event->type() == QEvent::MouseButtonPress)
	{
		QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
		if (mouseEvent->button() == Qt::LeftButton)
		{
			QWebView *view = dynamic_cast<QWebView*>(watched);
			QPoint pos = view->mapFromGlobal(mouseEvent->globalPos());
			QWebFrame *frame = view->page()->frameAt(mouseEvent->pos());
			if (frame != NULL)
			{
				QWebHitTestResult hitTestResult = frame->hitTestContent(pos);
                QWebElement welemTemp = hitTestResult.element();
                QWebElement elemCurrent = FindCloserWidget(welemTemp);
				// if the clicked elem is not the same as the previously clicked
				if (elemCurrent != m_old_click_element)
				{
					// Change color
					ChangeClickedElemColor(elemCurrent);
					// Message to print
					m_strCurrentElemId = elemCurrent.attribute("id");
					// Emit message
					Q_EMIT mouseLeftClickedOverElem(m_strCurrentElemId);
				}
			}
		}
	}
	return false;
}
开发者ID:jamal-fuma,项目名称:WtDesigner,代码行数:64,代码来源:mywebview.cpp

示例2: browserBack

void BrowserFrame::browserBack()
{
	QWebView *browser = static_cast<QWebView *>(currentWidget());
	if (browser != 0) browser->back();
}
开发者ID:caribe,项目名称:Webpedia-Reader,代码行数:5,代码来源:browserframe.cpp

示例3: parentWidget

void ClickToFlash::findElement()
{
    if (!m_toolButton) {
        return;
    }

    QWidget* parent = parentWidget();
    QWebView* view = 0;
    while (parent) {
        if (QWebView* aView = qobject_cast<QWebView*>(parent)) {
            view = aView;
            break;
        }
        parent = parent->parentWidget();
    }
    if (!view) {
        return;
    }

    QPoint objectPos = view->mapFromGlobal(m_toolButton->mapToGlobal(m_toolButton->pos()));
    QWebFrame* objectFrame = view->page()->frameAt(objectPos);
    QWebHitTestResult hitResult;
    QWebElement hitElement;

    if (objectFrame) {
        hitResult = objectFrame->hitTestContent(objectPos);
        hitElement = hitResult.element();
    }

    if (!hitElement.isNull() && (hitElement.tagName().compare("embed", Qt::CaseInsensitive) == 0 ||
                                 hitElement.tagName().compare("object", Qt::CaseInsensitive) == 0)) {
        m_element = hitElement;
        return;
    }

    // HitTestResult failed, trying to find element by src
    // attribute in elements at all frames on page (less accurate)

    QList<QWebFrame*> frames;
    frames.append(objectFrame);
    m_mainFrame = view->page()->mainFrame();
    frames.append(m_mainFrame);

    while (!frames.isEmpty()) {
        QWebFrame* frame = frames.takeFirst();
        if (!frame) {
            continue;
        }
        QWebElement docElement = frame->documentElement();

        QWebElementCollection elements;
        elements.append(docElement.findAll(QLatin1String("embed")));
        elements.append(docElement.findAll(QLatin1String("object")));

        foreach(const QWebElement & element, elements) {
            if (!checkElement(element) && !checkUrlOnElement(element)) {
                continue;
            }
            m_element = element;
            return;
        }
        frames += frame->childFrames();
    }
}
开发者ID:Longer,项目名称:qupzilla,代码行数:64,代码来源:clicktoflash.cpp

示例4: test2

void test2(){
	QWebView *view = new QWebView;
	view->load(QUrl("http://127.0.0.1/user-center.html"));
	view->show();
}
开发者ID:CUITCHE,项目名称:ZhiFan-Customer,代码行数:5,代码来源:main.cpp

示例5: renderHints

void tst_QWebView::renderHints()
{
    QWebView webView;

    // default is only text antialiasing
    QVERIFY(!(webView.renderHints() & QPainter::Antialiasing));
    QVERIFY(webView.renderHints() & QPainter::TextAntialiasing);
    QVERIFY(!(webView.renderHints() & QPainter::SmoothPixmapTransform));
    QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing));

    webView.setRenderHint(QPainter::Antialiasing, true);
    QVERIFY(webView.renderHints() & QPainter::Antialiasing);
    QVERIFY(webView.renderHints() & QPainter::TextAntialiasing);
    QVERIFY(!(webView.renderHints() & QPainter::SmoothPixmapTransform));
    QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing));

    webView.setRenderHint(QPainter::Antialiasing, false);
    QVERIFY(!(webView.renderHints() & QPainter::Antialiasing));
    QVERIFY(webView.renderHints() & QPainter::TextAntialiasing);
    QVERIFY(!(webView.renderHints() & QPainter::SmoothPixmapTransform));
    QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing));

    webView.setRenderHint(QPainter::SmoothPixmapTransform, true);
    QVERIFY(!(webView.renderHints() & QPainter::Antialiasing));
    QVERIFY(webView.renderHints() & QPainter::TextAntialiasing);
    QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform);
    QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing));

    webView.setRenderHint(QPainter::SmoothPixmapTransform, false);
    QVERIFY(webView.renderHints() & QPainter::TextAntialiasing);
    QVERIFY(!(webView.renderHints() & QPainter::SmoothPixmapTransform));
    QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing));
}
开发者ID:325116067,项目名称:semc-qsd8x50,代码行数:33,代码来源:tst_qwebview.cpp

示例6: GoBack

void QtMainWindow::GoBack(int index)
{
    QWebView* wv = (index < tabViews.size()) && (index >= 0) ? tabViews[index] : ui->webView;
    if (wv)
        wv->back();
}
开发者ID:nkm687,项目名称:rhodes,代码行数:6,代码来源:QtMainWindow.cpp

示例7: settings

void MainWindow::on_pushButton_5_clicked() //sql tab
{

    ui->progressBar->setValue(0);
    QString path = QCoreApplication::applicationDirPath() + "/";
    QSettings settings(path+"settings.ini", QSettings::IniFormat);
    QString webhost = settings.value("host").toString();
    QString webtoken = settings.value("token").toString();

    if(!ui->lineEdit_4->text().contains("http"))
    {
        QMessageBox::critical(this,"Error","There are two possible reasons either you need to enter a valid url or the prefix 'http' is missing!");
    }else if(ui->comboBox_3->currentIndex() == 1 && ui->lineEdit_5->text().isEmpty())
    {
        QMessageBox::critical(this,"Error","Please enter the variables in the POST field!");
    }else{
        //sqli scan
        QWebView *addsql = new QWebView; //instancia o pedido http GET
        QString url = ui->lineEdit_4->text();
        QString metodo = ui->comboBox_3->currentText();
        QString postdata2 = QUrl::toPercentEncoding(ui->lineEdit_5->text());

        QFile ficheiro(QApplication::applicationDirPath() + "/strings.txt");
        QStringList strings;
        int numlinhas=0;
        if (ficheiro.open(QIODevice::ReadOnly | QIODevice::Text))
        {
            QTextStream input(&ficheiro);
            while (!input.atEnd()) {
                strings += input.readLine();
                numlinhas++;
        }


         QFile ficheiro2(QApplication::applicationDirPath() + "/erros.txt");
         QStringList erros;
         int totallinhas=0;
         if (ficheiro2.open(QIODevice::ReadOnly | QIODevice::Text))
         {
            QTextStream in(&ficheiro2);
            while (!in.atEnd())
            {
                erros += in.readLine();
                totallinhas++;
            }



        }

        QNetworkRequest request(url);
        request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/x-www-form-urlencoded"));

        for(int i=0;i < numlinhas;i++)
        {
            QByteArray postdata; postdata.append(ui->lineEdit_5->text() + strings[i]);


            if(ui->comboBox_3->currentIndex() == 0){
                ui->webView_3->load(url+strings[i]);
            }else if(ui->comboBox_3->currentIndex() == 1){

                ui->webView_3->load(request,QNetworkAccessManager::PostOperation, postdata);
            }


             // qDebug() << url+strings[i];
               ui->progressBar->setValue(i*(100/numlinhas));

            QTime delay = QTime::currentTime().addSecs(3);
            while( QTime::currentTime() < delay )
            QCoreApplication::processEvents(QEventLoop::AllEvents, 100);

            for(int j=0;j< totallinhas;j++)
            {
                qDebug() << erros[j];
            if(ui->webView_3->page()->mainFrame()->toHtml().contains(erros[j]))
            {

              ui->progressBar->setValue(100);
              QMessageBox::information(this,"Results","This website may be vulnerable to SQL Injection!");

              QUrl url2 = "http://"+webhost+"/vulndb/includes/add.php?add&tabela=sqli&token="+webtoken+"&url="+url+"&metodo="+metodo+"&postdata="+postdata2+"&vuln=1";
              addsql->load(url2);

              return;
            }


            }
        //return;

        }
        ui->progressBar->setValue(100);
        QMessageBox::information(this,"Results","This website does not appear to be vulnerable to SQL Injection!");

        QUrl url2 = "http://"+webhost+"/vulndb/includes/add.php?add&tabela=sqli&token="+webtoken+"&url="+url+"&metodo="+metodo+"&postdata="+postdata2+"&vuln=0";
        addsql->load(url2);
    }
}
//.........这里部分代码省略.........
开发者ID:nsuchy,项目名称:vuln-scanner,代码行数:101,代码来源:mainwindow.cpp

示例8: update

void QWebViewPrivate::update(const QRect & dirtyRect)
{
    view->update(dirtyRect);
}
开发者ID:Androtos,项目名称:toolchain_benchmark,代码行数:4,代码来源:qwebview.cpp

示例9: setInputMethodEnabled

void QWebViewPrivate::setInputMethodEnabled(bool enable)
{
    view->setAttribute(Qt::WA_InputMethodEnabled, enable);
}
开发者ID:Androtos,项目名称:toolchain_benchmark,代码行数:4,代码来源:qwebview.cpp

示例10: palette

QPalette QWebViewPrivate::palette() const
{
    return view->palette();
}
开发者ID:Androtos,项目名称:toolchain_benchmark,代码行数:4,代码来源:qwebview.cpp

示例11: scroll

void QWebViewPrivate::scroll(int dx, int dy, const QRect& rectToScroll)
{
    view->scroll(qreal(dx), qreal(dy), rectToScroll);
}
开发者ID:Androtos,项目名称:toolchain_benchmark,代码行数:4,代码来源:qwebview.cpp

示例12: updateCursor

void QWebViewPrivate::updateCursor(const QCursor& cursor)
{
    view->setCursor(cursor);
}
开发者ID:Androtos,项目名称:toolchain_benchmark,代码行数:4,代码来源:qwebview.cpp

示例13: cursor

QCursor QWebViewPrivate::cursor() const
{
    return view->cursor();
}
开发者ID:Androtos,项目名称:toolchain_benchmark,代码行数:4,代码来源:qwebview.cpp

示例14: m_dumpPixels

DumpRenderTree::DumpRenderTree()
    : m_dumpPixels(false)
    , m_stdin(0)
    , m_enableTextOutput(false)
    , m_standAloneMode(false)
    , m_graphicsBased(false)
    , m_persistentStoragePath(QString(getenv("DUMPRENDERTREE_TEMP")))
{

    QByteArray viewMode = getenv("QT_DRT_WEBVIEW_MODE");
    if (viewMode == "graphics")
        setGraphicsBased(true);

    DumpRenderTreeSupportQt::overwritePluginDirectories();
    DumpRenderTreeSupportQt::activeMockDeviceOrientationClient(true);
    QWebSettings::enablePersistentStorage(m_persistentStoragePath);

    m_networkAccessManager = new NetworkAccessManager(this);
    // create our primary testing page/view.
    if (isGraphicsBased()) {
        WebViewGraphicsBased* view = new WebViewGraphicsBased(0);
        m_page = new WebPage(view, this);
        view->setPage(m_page);
        m_mainView = view;
    } else {
        QWebView* view = new QWebView(0);
        m_page = new WebPage(view, this);
        view->setPage(m_page);
        m_mainView = view;
    }
    // Use a frame group name for all pages created by DumpRenderTree to allow
    // testing of cross-page frame lookup.
    DumpRenderTreeSupportQt::webPageSetGroupName(m_page, "org.webkit.qt.DumpRenderTree");

    m_mainView->setContextMenuPolicy(Qt::NoContextMenu);
    m_mainView->resize(QSize(LayoutTestController::maxViewWidth, LayoutTestController::maxViewHeight));

    // clean up cache by resetting quota.
    qint64 quota = webPage()->settings()->offlineWebApplicationCacheQuota();
    webPage()->settings()->setOfflineWebApplicationCacheQuota(quota);

    // create our controllers. This has to be done before connectFrame,
    // as it exports there to the JavaScript DOM window.
    m_controller = new LayoutTestController(this);
    connect(m_controller, SIGNAL(showPage()), this, SLOT(showPage()));
    connect(m_controller, SIGNAL(hidePage()), this, SLOT(hidePage()));

    // async geolocation permission set by controller
    connect(m_controller, SIGNAL(geolocationPermissionSet()), this, SLOT(geolocationPermissionSet()));

    connect(m_controller, SIGNAL(done()), this, SLOT(dump()));
    m_eventSender = new EventSender(m_page);
    m_textInputController = new TextInputController(m_page);
    m_plainTextController = new PlainTextController(m_page);
    m_gcController = new GCController(m_page);

    // now connect our different signals
    connect(m_page, SIGNAL(frameCreated(QWebFrame *)),
            this, SLOT(connectFrame(QWebFrame *)));
    connectFrame(m_page->mainFrame());

    connect(m_page, SIGNAL(loadFinished(bool)),
            m_controller, SLOT(maybeDump(bool)));
    // We need to connect to loadStarted() because notifyDone should only
    // dump results itself when the last page loaded in the test has finished loading.
    connect(m_page, SIGNAL(loadStarted()),
            m_controller, SLOT(resetLoadFinished()));
    connect(m_page, SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested()));
    connect(m_page, SIGNAL(printRequested(QWebFrame*)), this, SLOT(dryRunPrint(QWebFrame*)));

    connect(m_page->mainFrame(), SIGNAL(titleChanged(const QString&)),
            SLOT(titleChanged(const QString&)));
    connect(m_page, SIGNAL(databaseQuotaExceeded(QWebFrame*,QString)),
            this, SLOT(dumpDatabaseQuota(QWebFrame*,QString)));
    connect(m_page, SIGNAL(applicationCacheQuotaExceeded(QWebSecurityOrigin *, quint64)),
            this, SLOT(dumpApplicationCacheQuota(QWebSecurityOrigin *, quint64)));
    connect(m_page, SIGNAL(statusBarMessage(const QString&)),
            this, SLOT(statusBarMessage(const QString&)));

    QObject::connect(this, SIGNAL(quit()), qApp, SLOT(quit()), Qt::QueuedConnection);

    DumpRenderTreeSupportQt::setDumpRenderTreeModeEnabled(true);
    QFocusEvent event(QEvent::FocusIn, Qt::ActiveWindowFocusReason);
    QApplication::sendEvent(m_mainView, &event);
}
开发者ID:mcgrawp,项目名称:webkit-webcl,代码行数:85,代码来源:DumpRenderTreeQt.cpp

示例15: mimeType

QObject* WebPluginFactory::create (const QString& _mimeType, const QUrl& url, const QStringList& argumentNames, const QStringList& argumentValues) const
{
    //kDebug() << _mimeType << url << argumentNames;
    QString mimeType (_mimeType.trimmed());
    if (mimeType.isEmpty()) {
        extractGuessedMimeType (url, &mimeType);
    }

    const bool noPluginHandling = WebKitSettings::self()->isInternalPluginHandlingDisabled();

    if (!noPluginHandling && WebKitSettings::self()->isLoadPluginsOnDemandEnabled()) {
        const uint id = pluginId(url, argumentNames, argumentValues);
        if (!mPluginsLoadedOnDemand.contains(id)) {
            FakePluginWidget* widget = new FakePluginWidget(id, url, mimeType);
            connect(widget, SIGNAL(pluginLoaded(uint)), this, SLOT(loadedPlugin(uint)));
            return widget;
        }
    }

    Q_ASSERT(mPart); // should never happen!!
    KParts::ReadOnlyPart* part = 0;
    QWebView* view = (mPart ? mPart->view() : 0);

    if (noPluginHandling || !excludedMimeType(mimeType)) {
        QWebFrame* frame = (view ? view->page()->currentFrame() : 0);
        if (frame) {
            part = createPartInstanceFrom(mimeType, argumentNames, argumentValues, view, frame);
        }
    }

    kDebug() << "Asked for" << mimeType << "plugin, got" << part;

    if (part) {
        connect (part->browserExtension(), SIGNAL (openUrlNotify()),
                 mPart->browserExtension(), SIGNAL (openUrlNotify()));

        connect (part->browserExtension(), SIGNAL (openUrlRequest (KUrl, KParts::OpenUrlArguments, KParts::BrowserArguments)),
                 mPart->browserExtension(), SIGNAL (openUrlRequest (KUrl, KParts::OpenUrlArguments, KParts::BrowserArguments)));

        // Check if this part is scriptable
        KParts::ScriptableExtension* scriptExt = KParts::ScriptableExtension::childObject(part);
        if (!scriptExt) {
            // Try to fall back to LiveConnectExtension compat
            KParts::LiveConnectExtension* lc = KParts::LiveConnectExtension::childObject(part);
            if (lc) {
                scriptExt = KParts::ScriptableExtension::adapterFromLiveConnect(part, lc);
            }
        }

        if (scriptExt) {
            scriptExt->setHost(KParts::ScriptableExtension::childObject(mPart));
        }

        QMap<QString, QString> metaData = part->arguments().metaData();
        QString urlStr = url.toString (QUrl::RemovePath | QUrl::RemoveQuery | QUrl::RemoveFragment);
        metaData.insert ("PropagateHttpHeader", "true");
        metaData.insert ("referrer", urlStr);
        metaData.insert ("cross-domain", urlStr);
        metaData.insert ("main_frame_request", "TRUE");
        metaData.insert ("ssl_activate_warnings", "TRUE");

        KWebPage *page = (view ? qobject_cast<KWebPage*>(view->page()) : 0);

        if (page) {
            const QString scheme = page->currentFrame()->url().scheme();
            if (page && (QString::compare (scheme, QL1S ("https"), Qt::CaseInsensitive) == 0 ||
                         QString::compare (scheme, QL1S ("webdavs"), Qt::CaseInsensitive) == 0))
                metaData.insert ("ssl_was_in_use", "TRUE");
            else
                metaData.insert ("ssl_was_in_use", "FALSE");
        }

        KParts::OpenUrlArguments openUrlArgs = part->arguments();
        openUrlArgs.metaData() = metaData;
        openUrlArgs.setMimeType(mimeType);
        part->setArguments(openUrlArgs);
        QMetaObject::invokeMethod(part, "openUrl", Qt::QueuedConnection, Q_ARG(KUrl, KUrl(url)));
        return part->widget();
    }

    return 0;
}
开发者ID:netrunner-debian-kde-extras,项目名称:webkitkde,代码行数:82,代码来源:webpluginfactory.cpp


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