Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. Force URL in QWebView
Forum Updated to NodeBB v4.3 + New Features

Force URL in QWebView

Scheduled Pinned Locked Moved Qt WebKit
3 Posts 2 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cccm62
    wrote on last edited by
    #1

    Hi,

    I'd like to force domain loaded in QWebView.

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

    For example, I tryed like this:

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

    // ...

    void MainWindow::forceDomain()
    {
    QString loc = view->url().toString();
    if ( !loc.startsWith("http://www.domain.xxx") )
    {
    QUrl url = QUrl("http://www.domain.xxx");
    view->load(url);
    view->setFocus();
    }
    }@

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

    Any suggestion?
    Thx, Cedric

    1 Reply Last reply
    0
    • B Offline
      B Offline
      brcontainer
      wrote on last edited by
      #2

      Post all the code,
      because failure can be anywhere.

      QT project: https://github.com/brcontainer/qt-helper

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cccm62
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved