PDA

View Full Version : Need help in Qwebview, find test in HTML page



keyurparekh
18th May 2011, 05:46
Hi all,

I am currently stuck in one problem. I am opening one HTML page using webkit module of QT. The is opening perfectly. But now i want to find text in that page.

How can i do that? Please give me some code example so that i can implement it. Below is my code to open HTML page.

.H file


class my2 : public QWidget , private Ui_Form
{
Q_OBJECT

public:
explicit my2(QWidget *parent = 0, Qt::WindowFlags f = 0 );
~my2();

public:
void setBaseUrl(const QUrl &url);

private:
QUrl baseUrl;
};

In C file


my2::my2(QWidget *parent, Qt::WindowFlags f ) :
QWidget(parent,f)
{
setupUi(this);
baseUrl = "http://www.itisl.com/Luminum/E-Book/Infotek/Physics/ch8/index.html";
setBaseUrl(baseUrl);
}

void my2::setBaseUrl(const QUrl &url)
{
webView->setUrl(url);
}

I have use Qwebview widget.
By this i m able to open HTML page perfectly. Now how can i find any word in this HTML page. Please tell me some solution so that i can solve this problem.

Thanks in Advance.

Regards,
Keyur Parekh

pkj
18th May 2011, 08:06
You want to find a webelement in html page? Or just a word in it.
Refer QRegExp class. You can pretty much do anything if you know this class well enough.

keyurparekh
18th May 2011, 10:01
I need to find word from HTML page. If i type any word it should highlight that word in page.

wysota
18th May 2011, 14:29
To do it properly you need to traverse all elements of the DOM using QWebElement API, look for your text and act accordingly.