Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Archived:Load a Selected Web Search Engine in a QWebView

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Qt Quick should be used for all UI development on mobile devices. The approach described in this article (based on QWidget) is deprecated.


Article Metadata
Tested with
Devices(s): S60 Emulator
Compatibility
Platform(s): S60 3rd Edition, FP1, FP2
S60 5th Edition
Symbian
Article
Keywords: QPushButton,QWebView
Created: mind_freak (08 Jul 2009)
Last edited: hamishwillee (11 Oct 2012)

Contents

OverView

This article allows you to select a search engine from a list and enter text, then launches the search engine using a QWebView. The application is limited because after first search the native interface is no longer visible and we then need to use the search engine's web page directly.

This example makes the use of following classes:

  • QWebView - Provides a widget that is used to view and edit web documents.
  • QPushButton - Provides a command button to search.


Preconditions

  • Download and Install the Qt SDK

source code

cpp file

#include "engine.h"
#include "ui_engine.h"
 
engine::engine(QWidget *parent)
: QWidget(parent), ui(new Ui::engineClass)
{
ui.setupUi(this);
msg=new QMessageBox();
ui.comboBox.addItem("--Select--");
ui.comboBox.addItem("altavista.com");
ui.comboBox.addItem("ask.com");
ui.comboBox.addItem("google.com");
ui.comboBox.addItem("goto.com");
ui.comboBox.addItem("hotbot.com");
ui.comboBox.addItem("looksmart.com");
ui.comboBox.addItem("lycos.com");
ui.comboBox.addItem("metacrawler.com");
ui.webView.hide();
ui.Bar.setValue(0);
QObject::connect(ui.search,SIGNAL(clicked()),this,SLOT(viral()));
QObject::connect(ui.webView,SIGNAL(loadProgress(int)),ui.Bar,SLOT(setValue(int)));
 
}
 
engine::~engine()
{
delete ui;
}
void engine::viral()
{
 
if(ui.comboBox.currentText()=="--Select--")
{
msg->setText("Please select Search Engine");
msg->exec();
 
}
else if(ui.comboBox.currentText()=="altavista.com")//Search on specific website by comparing strings
{
ui.label.setText(ui.comboBox.currentText());
ui.line.hide();
ui.comboBox.hide();
ui.search.hide();
str="http://www.altavista.com/cgi-bin/query?pg=q&what=web&fmt=.&q=";
str1=ui.line.text();
str3=str+str1;
ui.webView.show();
ui.webView.load(QUrl(str3));
 
}
else if(ui.comboBox.currentText()=="ask.com")
{
ui.label.setText(ui.comboBox.currentText());
ui.line.hide();
ui.comboBox.hide();
ui.search.hide();
str="http://www.ask.com/main/askjeeves.asp?x=22&y=13&ask=";
str1=ui.line.text();
str3=str+str1;
ui.webView.show();
ui.webView.load(QUrl(str3));
}
else if(ui.comboBox.currentText()=="google.com")
{
ui.label.setText(ui.comboBox.currentText());
ui.line.hide();
ui.comboBox.hide();
ui.search.hide();
str="http://www.google.com/search?btnG=Google+Search&q=";
str1=ui.line.text();
str3=str+str1;
ui.webView.show();
ui.webView.load(QUrl(str3));
}
else if (ui.comboBox.currentText()=="goto.com")
{
ui.label.setText(ui.comboBox.currentText());
ui.line.hide();
ui.comboBox.hide();
ui.search.hide();
str="http://www.goto.com/d/search/?type=home&tm=1&Keywords=";
str1=ui.line.text();
str3=str+str1;
ui.webView.show();
ui.webView.load(QUrl(str3));
}
else if(ui.comboBox.currentText()=="hotbot.com")
{
ui.label.setText(ui.comboBox.currentText());
ui.line.hide();
ui.comboBox.hide();
ui.search.hide();
str="http://www.hotbot.com/search.html?SM=MC&_v=1.0&MT=";
str1=ui.line.text();
str3=str+str1;
ui.webView.show();
ui.webView.load(QUrl(str3));
}
 
else if(ui.comboBox.currentText()=="looksmart.com")
{
ui.label.setText(ui.comboBox.currentText());
ui.line.hide();
ui.comboBox.hide();
ui.search.hide();
str="http://www.looksmart.com/r_search?look=&key=";
str1=ui.line.text();
str3=str+str1;
ui.webView.show();
ui.webView.load(QUrl(str3));
}
else if(ui.comboBox.currentText()=="lycos.com")
{
ui.label.setText(ui.comboBox.currentText());
ui.line.hide();
ui.comboBox.hide();
ui.search.hide();
str="http://www.lycos.com/cgi-bin/pursuit?query=";
str1=ui.line.text();
str3=str+str1;
ui.webView->show();
ui->webView->load(QUrl(str3));
}
else if(ui->comboBox->currentText()=="metacrawler.com")
{
ui->label->setText(ui->comboBox->currentText());
ui->line->hide();
ui->comboBox->hide();
ui->search->hide();
str="http://www.metacrawler.com/cgi-bin/nph-metaquery.p?general=";
str1=ui.line.text();
str3=str+str1;
ui.webView.show();
ui.webView.load(QUrl(str3));
}
else
{
 
exit(1);
}
 
 
}

Screenshot

Searchme.JPG

Searchme1.JPG

This page was last modified on 11 October 2012, at 01:14.
57 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×