I'm probably trying to go about this the wrong way, but I've been trying to automatically sign a user into a website using the load function of QWebView to perform the post operation.
The problem is, upon signing in I'm told that I'm required to accept cookies to sign in and I'm just not sure how to resolve this issue.

Here's the current code responsible for performing the post operation (with some minor alterations for privacy's sake).
Qt Code:
  1. QNetworkAccessManager *m;
  2. QNetworkRequest r;
  3. QNetworkCookieJar *c = new QNetworkCookieJar();
  4. QByteArray payload;
  5. payload.append("login=" + username + "&register=0&password=" + password + "&remember=1&cookie_check=1&_xfToken=&redirect=http://website.com/shoutbox/popup");
  6. r.attribute(QNetworkRequest::CookieSaveControlAttribute, QVariant(true));
  7. r.setUrl(QUrl("http://website.com/login/login"));
  8. r.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*;q=0.8");
  9. r.setRawHeader("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.3");
  10. r.setRawHeader("Accept-Language", "en-US,en;q=0.5");
  11. r.setHeader(QNetworkRequest::ContentLengthHeader, QVariant(QString::number(payload.length())));
  12. r.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
  13. r.setRawHeader("Referer", "http://website.com/login");
  14. r.setRawHeader("Host", "www.website.com");
  15. m = new QNetworkAccessManager();
  16. m->setCookieJar(c);
  17. ui->webView->page()->setNetworkAccessManager(m);
  18. ui->webView->load(r, QNetworkAccessManager::PostOperation, payload);
To copy to clipboard, switch view to plain text mode 

Could I just rewrite the post request separate from the web view, handle the response manually and then pass the cookies to the web view or is there a way to get this working as it is?
I'm feel like I'm just missing something really obvious. >_>

Thank you.