Important: Please read the Qt Code of Conduct -

Force URL in QWebView

  • Hi,

    I'd like to force domain loaded in QWebView.

    i.e. if the url doesn't start by "http(s)://",
    => then abort and load "http(s)://"

    For example, I tryed like this:

    @connect(view, SIGNAL(urlChanged(QUrl)), SLOT(forceDomain()));

    // ...

    void MainWindow::forceDomain()
    QString loc = view->url().toString();
    if ( !loc.startsWith("") )
    QUrl url = QUrl("");

    But it seems the code is looping (?)
    The application fail with code "1073741819"

    Any suggestion?
    Thx, Cedric

  • Post all the code,
    because failure can be anywhere.

  • Thanks for your reply

    I begin with Qt (and with C++) and I realized that I had to do otherwise

    I have override QNetworkAccessManager and test if "req.url().host();" endsWith the domain

    Everything is fine now

    Thx, Cedric

Log in to reply