Results 1 to 7 of 7

Thread: QWebView and QWebPage not showing dialog authentication

  1. #1
    Join Date
    Mar 2011
    Location
    Greece
    Posts
    23
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QWebView and QWebPage not showing dialog authentication

    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??


    Qt Code:
    1. if (webPage)
    2. ui->webView->setPage(webPage);
    3.  
    4.  
    5. QUrl url(QString("http://localhost/text/"));
    6. ui->webView->load(url);
    7.  
    8. url.setUserName("admin");
    9. url.setPassword("admin");
    To copy to clipboard, switch view to plain text mode 

    Any help would be appreciated!

  2. #2
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QWebView and QWebPage not showing dialog authentication

    Just a "bad" guess: shouldn't u set the user name and password before you load the url?

  3. #3
    Join Date
    Mar 2011
    Location
    Greece
    Posts
    23
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWebView and QWebPage not showing dialog authentication

    I saw it later and i changed it but the problem remains...

  4. #4
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QWebView and QWebPage not showing dialog authentication

    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?

  5. #5
    Join Date
    Mar 2011
    Location
    Greece
    Posts
    23
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWebView and QWebPage not showing dialog authentication

    I am trying this :
    Qt Code:
    1. ui->webView->setPage(webPage);
    2.  
    3.  
    4. QUrl url(QString("http://localhost/text/"));
    5.  
    6. // ui->webView->load(url);
    7.  
    8. manager=ui->webView->page()->networkAccessManager();
    9.  
    10. connect(manager,SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),this,SLOT(provideAuthentication(QNetworkReply*,QAuthenticator*)));
    11.  
    12. QNetworkRequest req(url);
    13.  
    14. manager->get(req);
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void Example::provideAuthentication(QNetworkReply *reply, QAuthenticator *auth)
    2. {
    3. auth->setUser("admin");
    4. auth->setPassword("admin");
    5. }
    To copy to clipboard, switch view to plain text mode 



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

  6. #6
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QWebView and QWebPage not showing dialog authentication

    Didn't it work with "ui->webView->load(url);" ? instead of creating network request and manager to get the reply?

  7. #7
    Join Date
    Mar 2011
    Location
    Greece
    Posts
    23
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWebView and QWebPage not showing dialog authentication

    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).

Similar Threads

  1. Qurl+poppler
    By wakitowaki in forum Qt Programming
    Replies: 1
    Last Post: 15th June 2011, 19:39
  2. Replies: 1
    Last Post: 29th March 2011, 10:12
  3. QUrl and EUC-JP
    By Ignacio Serantes in forum Qt Programming
    Replies: 1
    Last Post: 22nd February 2009, 15:19
  4. QUrl: file in the current dir
    By lirq in forum Qt Programming
    Replies: 5
    Last Post: 6th January 2009, 11:52
  5. Problem with qurl and fromlocalfile
    By zorro68 in forum Qt Programming
    Replies: 1
    Last Post: 19th June 2008, 19:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.