Browse web page
-
Use a QWebview for displaying a webpage.
Use QWebview's setUrl(const QUrl & url) method for setting the URL you wish to display.- pass QUrl as something like QUrl("http://www.google.com").
-
In Qt4.8.x under the header file "QUrl" (#include <QUrl>) the class has several constructors of which, for your purpose, ' QUrl ( const QString & url ) ' or perhaps ' QUrl ( const QString & url, ParsingMode parsingMode ) ', would be most appropriate, but it depends of what you are looking for.
Another option is to use th 'QUrl ()' constructor and then use 'setUrl ( const QString & url )' or ' setUrl ( const QString & url, ParsingMode parsingMode )'.
Example:
@
#include <QUrl> //Qt UR
#include <memory> // smart pointer
#include <string>
int main(){
std::string url;// ..... some other code .....
if(url.empty()){
std::shared_ptr<QUrl > myUrl;
}else{
std::shared_ptr<QUrl > myUrl(url);
}// ..... some other code .....
// if the non parameterized constructor was used, use default URL address
if(url.empty()){
myUrl->setUrl("http://www.bing.com") ;
}
return 0;
}@
I have NOT checked the code, but it will help you understand the main concept I hope; but if not, keep asking, folks here a very help full.