PDA

View Full Version : QWeb



ttimt
15th December 2012, 07:30
1. how do you store cookies using QNetworkCookieJar, and maybe put inside a user folder?

2. how does this QWebPage::history() works if im gonna show these history inside a text edit.?

3. I have a Save Page option to save the page as html, and i set QWebSettings::enablePersistentStorage(Pathname), then how im gonna write the downloadlinktodisk code?


QWebPage abc;
abc.DownloadLinkToDisk; //not this
thx

anda_skoa
15th December 2012, 17:40
1. how do you store cookies using QNetworkCookieJar, and maybe put inside a user folder?


The documentation says "If you want to save the cookies, you should derive from this class and implement the saving to disk to your own storage format."
So as suggested, derive from QNetworkCookieJar, implement either a save method or save in you class' destructor.



2. how does this QWebPage::history() works if im gonna show these history inside a text edit.?

I think I don't understand that question. The QWebHistory object basically holds two lists: one of items that have information about pages you can go back to and one with information about pages you can go forward to.



3. I have a Save Page option to save the page as html, and i set QWebSettings::enablePersistentStorage(Pathname), then how im gonna write the downloadlinktodisk code?


You connect to the dowloadRequested signal and then use QNetworkAccessManager API to actually perform the download.
Persistant Storage is a totally different feature, not related to "save to disk" at all.

Cheers,
_

ttimt
17th December 2012, 13:11
2. The QWebHistory object basically holds two lists: one of items that have information about pages you can go back to and one with information about pages you can go forward to.

So I will need to save all visited sites into a file and loads it if the user click "History" button?


3. You connect to the dowloadRequested signal and then use QNetworkAccessManager API to actually perform the download.
Persistant Storage is a totally different feature, not related to "save to disk" at all.


can you please show the code? If the user click "Save Page", I went to the slot of this


void on_Button_Clicked(){

//downloadRequested(QNetworkRequest)
//QNetworkAccessManager *networkManager = ui->webView->url()


}

anda_skoa
19th December 2012, 14:05
So I will need to save all visited sites into a file and loads it if the user click "History" button?

What do you want to achieve?




can you please show the code? If the user click "Save Page", I went to the slot of this


Ah, save page is a button.

Well, in the slot you do this


QWebPage *webPage = ui->webView->page();
QWebFrame *webFrame = webPage->mainFrame();

QString content = webFrame->toHtml();
// content now contains the HTML of the loaded URL


Cheers,
_