PDA

View Full Version : QWebView and QWebPage not showing dialog authentication



milli
16th June 2011, 02:53
i have to access a page that asks me username and password,the page shows the message Authentication required!..
According to QWebPage class (code) on the constructor is done the authorization usind QNetworkAccessmanager e.t.c.

Where I am wrong??




if (webPage)
ui->webView->setPage(webPage);


QUrl url(QString("http://localhost/text/"));
ui->webView->load(url);

url.setUserName("admin");
url.setPassword("admin");



Any help would be appreciated!

Rachol
16th June 2011, 12:59
Just a "bad" guess: shouldn't u set the user name and password before you load the url?

milli
16th June 2011, 13:10
I saw it later and i changed it but the problem remains...

Rachol
16th June 2011, 13:30
What about using QNetworkAccessManager * QWebPage::networkAccessManager () const and using it to connect void authenticationRequired ( QNetworkReply * reply, QAuthenticator * authenticator ) to your slot, where you can do the authentication?

milli
16th June 2011, 14:09
I am trying this :

ui->webView->setPage(webPage);


QUrl url(QString("http://localhost/text/"));

// ui->webView->load(url);

manager=ui->webView->page()->networkAccessManager();

connect(manager,SIGNAL(authenticationRequired(QNet workReply*,QAuthenticator*)),this,SLOT(provideAuth entication(QNetworkReply*,QAuthenticator*)));

QNetworkRequest req(url);

manager->get(req);


void Example::provideAuthentication(QNetworkReply *reply, QAuthenticator *auth)
{
auth->setUser("admin");
auth->setPassword("admin");
}



But nothing displays neither the warning authentication required....

Rachol
16th June 2011, 14:18
Didn't it work with "ui->webView->load(url);" ? instead of creating network request and manager to get the reply?

milli
16th June 2011, 15:03
No it didn't work.Normally it should...I don't know if it is important to refer but the url is: url="http://localhost/mod_perl/text.pl (Before i referred an example of a url).