Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. How to get a case insesitive attribute of a element in qt webkit
Forum Update on Monday, May 27th 2025

How to get a case insesitive attribute of a element in qt webkit

Scheduled Pinned Locked Moved Qt WebKit
1 Posts 1 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    developer
    wrote on last edited by
    #1

    i want to get the arttibe of a web element i can get it using http://doc.qt.nokia.com/4.6/qwebelement.html#attribute but its case sensitive i want if i want attribute href then if HREF or Href exits then it gives that results. also in the case of setting vale u attribut checking existence and removing an attribute i can do that but now case insensitive i have really searched deeply i am using qt c++ qtwebkit
    @#include "webview.h"
    #include <QMessageBox>
    webview::webview(QWidget *parent) :
    QWebView(parent)
    {
    openlinkinnewtab = new QAction("open link in new tab" , this);
    connect(openlinkinnewtab , SIGNAL(triggered()) , this , SLOT(linknewtab()));
    }
    void webview::contextMenuEvent(QContextMenuEvent * event)
    {
    QMenu * menu = new QMenu();
    menu->setVisible(true);
    QWebElement element = this->page()->mainFrame()->hitTestContent(event->pos()).element();
    QString tagname = this->page()->mainFrame()->hitTestContent(event->pos()).element().tagName().toLower();
    if(tagname == "img")
    {
    menu->addAction(this->pageAction(QWebPage::DownloadImageToDisk));
    menu->addAction(this->pageAction(QWebPage::CopyImageToClipboard));
    menu->addAction(this->pageAction(QWebPage::CopyImageUrlToClipboard));
    }
    if(tagname == "")
    {
    menu->addAction(this->pageAction(QWebPage::DownloadLinkToDisk));
    menu->addAction(this->pageAction(QWebPage::CopyLinkToClipboard));
    menu->addAction(openlinkinnewtab);
    openlinkinnewtab->setData(QVariant(element.attribute("" , tr("the default value"))));
    QMessageBox::information(this , tr("the url ") , tr("the url is %1").arg(element.attribute("Href" , tr("the default value"))));
    }
    if(tagname == "input" || tagname == "textarea")
    {
    menu->addAction(this->pageAction(QWebPage::Copy));
    menu->addAction(this->pageAction(QWebPage::Cut));
    menu->addAction(this->pageAction(QWebPage::Paste));
    menu->addAction(this->pageAction(QWebPage::Undo));
    menu->addAction(this->pageAction(QWebPage::Redo));
    menu->addAction(this->pageAction(QWebPage::SelectAll));
    }
    menu->exec(event->globalPos());
    }
    void webview::linknewtab()
    {
    emit linkinnewtab(openlinkinnewtab->data().toString());
    }
    @
    i have already seen this:
    http://stackoverflow.com/questions/9758897/how-to-get-a-case-insesitive-attribute-of-a-element-in-qt-webkit
    no anwsers there

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved