How to get a case insesitive attribute of a element in qt webkit
-
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