2010年12月24日 星期五

Qt Webkit demo

#include
#include
#include
#include

int main(int argc, char *argv[]){
QApplication a(argc, argv);
QWebView *view = new QWebView(0);
view->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal,Qt::ScrollBarAlwaysOff);
view->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
view->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
view->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
view->settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
view->load(QUrl("http://www.google.com.tw/"));
//view->load(QUrl("http://tw.yahoo.com/"));
view->setWindowTitle("hello QtWebKit");
view->show();
return a.exec();
}

修改.pro文件,加入:QT +=webkit

沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。