Nominate our 2022 Qt Champions!

How do I auth with QtWebView then open QtApplication?

  • Hi all,

    I'm attempting to build a game client using a mix of HTML5 and native.

    Upon launch, I want to pop open a QTWebView to my login page on my server, then once the player has authenticated, I want to close down the WebView, send the authenticated user token back from the server, and get into a native QtApplication running OpenGL (whatever the proper class name is)..

    I've created the WebView which pulls up my login page, but now I'm stuck on where to direct my research..

    I respect everyone's time too much to ask for a code sample (and I want to learn it heh), so even just a suggestion on what topic to start with would be greatly appreciated..

    thanks so much!

  • Maybe it is better to show simple QWidget for username & pass, after just send POST request with QNetworkAccessManager to the server and analyze response in finished slot.(for session ID or what ever the server response)

    But if QWebView is absolutely necessarily, then:

    1. you can create your NetworkAccessManager and set it for QWebView
      1.1 peek and anaylse response
    2. connect to QNetworkManager of QWebView
      2.1 peek and anaylse data

  • You need to have a QApplication running for the QWebView to do its job. The correct order would be:

    create QApplication

    set up basic things

    create a dialog containing the QWebView and show it

    rund QApplication's event loop with exec()

    in the dialog, if the login was successful, open your main mindow

    close the dialog by calling accept() and/or deleteLater()

  • Thanks @AcerExtensa and @Volker for the suggestions!

    I do need to show a QWebView to not only support Facebook / Twitter authentication, but also to make sure any latest updates to the game are shown for players.

    I've managed to create two windows that launch at the same time (probably under the umbrella of a QApplication idea that @Volker had)..

    So the next key to cracking this problem is to figure out how to listen for some kind of event from the WebView in order to close it up and open the other main window..

Log in to reply