Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QWebView blank screen
Forum Updated to NodeBB v4.3 + New Features

QWebView blank screen

Scheduled Pinned Locked Moved Solved General and Desktop
22 Posts 4 Posters 7.5k 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.
  • N nicholaslee

    @JonB Yes, I think so, im not totally sure how webview works. How would I load the page if its generated in JavaScript?

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #13

    @nicholaslee Didn't you say that same page is loading fine when you press the button?

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • N Offline
      N Offline
      nicholaslee
      wrote on last edited by
      #14

      @jsulm yes the button will open the browser and navigate to the URL.

      But webview is just displaying a blank screen. Is there anyway to view it?

      JonBJ 1 Reply Last reply
      0
      • N nicholaslee

        @jsulm yes the button will open the browser and navigate to the URL.

        But webview is just displaying a blank screen. Is there anyway to view it?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #15

        @nicholaslee
        Put in a slot for http://doc.qt.io/archives/qt-4.8/qwebview.html#loadFinished. Check you do get there, and the value of ok.

        1 Reply Last reply
        0
        • N Offline
          N Offline
          nicholaslee
          wrote on last edited by
          #16
          MainWindow::MainWindow(QWidget *parent) :
              QMainWindow(parent),
              ui(new Ui::MainWindow)
          {
              ui->setupUi(this);
          
              QString link = "https://nusmods.com/timetable/sem-1";
              ui->webView->load(QUrl(link));
          
              void QWebView::loadFinished(bool ok);
          }
          

          @JonB sorry im still new to slots, do I just put it in like this?

          It's giving me an error "invalid use of qualified-name 'QWebView::loadFinished"

          jsulmJ 1 Reply Last reply
          0
          • N nicholaslee
            MainWindow::MainWindow(QWidget *parent) :
                QMainWindow(parent),
                ui(new Ui::MainWindow)
            {
                ui->setupUi(this);
            
                QString link = "https://nusmods.com/timetable/sem-1";
                ui->webView->load(QUrl(link));
            
                void QWebView::loadFinished(bool ok);
            }
            

            @JonB sorry im still new to slots, do I just put it in like this?

            It's giving me an error "invalid use of qualified-name 'QWebView::loadFinished"

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #17

            @nicholaslee said in QWebView blank screen:

            void QWebView::loadFinished(bool ok);

            This declares a function!
            Please read http://doc.qt.io/qt-5/signalsandslots.html
            You need to do

            MainWindow::MainWindow(QWidget *parent) :
                QMainWindow(parent),
                ui(new Ui::MainWindow)
            {
                ui->setupUi(this);
            
                QString link = "https://nusmods.com/timetable/sem-1";
                ui->webView->load(QUrl(link));
            
                connect(ui->webView, &QWebView::loadFinished, this, &MainWindow::handleLoadFinished);
            }
            
            void MainWindow::handleLoadFinished(bool ok)
            {
            ...
            }
            

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            2
            • N Offline
              N Offline
              nicholaslee
              wrote on last edited by
              #18
              MainWindow::MainWindow(QWidget *parent) :
                  QMainWindow(parent),
                  ui(new Ui::MainWindow)
              {
                  ui->setupUi(this);
              
                  QString link = "https://nusmods.com/timetable/sem-1";
                  ui->webView->load(QUrl(link));
              
                  connect(ui->webView, &QWebView::loadFinished, this, &MainWindow::handleLoadFinished);
              
              }
              
              void MainWindow::handleLoadFinished(bool ok){
              
                  qDebug() << QString("Loaded");
              }
              

              @jsulm @JonB
              Ive put in a slot and yes it prints out loaded but the webview is not showing anything. Btw thanks for the help!

              JonBJ 1 Reply Last reply
              0
              • N nicholaslee
                MainWindow::MainWindow(QWidget *parent) :
                    QMainWindow(parent),
                    ui(new Ui::MainWindow)
                {
                    ui->setupUi(this);
                
                    QString link = "https://nusmods.com/timetable/sem-1";
                    ui->webView->load(QUrl(link));
                
                    connect(ui->webView, &QWebView::loadFinished, this, &MainWindow::handleLoadFinished);
                
                }
                
                void MainWindow::handleLoadFinished(bool ok){
                
                    qDebug() << QString("Loaded");
                }
                

                @jsulm @JonB
                Ive put in a slot and yes it prints out loaded but the webview is not showing anything. Btw thanks for the help!

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #19

                @nicholaslee
                You need to add qDebug() << ok; there, we need to know what value ok is being passed as.

                1 Reply Last reply
                1
                • N Offline
                  N Offline
                  nicholaslee
                  wrote on last edited by
                  #20

                  The value is passed as a 'true'

                  JonBJ 1 Reply Last reply
                  0
                  • N nicholaslee

                    The value is passed as a 'true'

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by
                    #21

                    @nicholaslee
                    Then, fortunately or unfortunately, we've sent you down a wild goose chase, insofar as QWebView confirms that it has successfully completed loading the content. But it's good to know!

                    Then I can only guess/suggest as per earlier that (assuming you say it is not a https or redirection issue) the web kit is having problems with the JavaScript content? Check the actual content received in the QWebPage/QWebFrame to verify it's what you see in a working browser, and see if there are any signals received indicating it's having problems with the content?

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      agarny
                      wrote on last edited by
                      #22

                      @nicholaslee, you apparently solved your problem (since this is labelled "SOLVED"), but I cannot see what you had to do, if anything, to solve it. Would you mind sharing your findings, if any? (Yes, I am having the same problem with a JavaScript-generated page. I have yet to fully investigate the issue though.)

                      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