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. [Solved]How to change dynamically QWebFrame contents?
Forum Updated to NodeBB v4.3 + New Features

[Solved]How to change dynamically QWebFrame contents?

Scheduled Pinned Locked Moved Qt WebKit
10 Posts 3 Posters 4.7k 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.
  • Z Offline
    Z Offline
    zither
    wrote on last edited by
    #1

    Dear all friends,

    I would like to know how to change dynamically QWebFrame contents?

    Thanks

    1 Reply Last reply
    0
    • L Offline
      L Offline
      loladiro
      wrote on last edited by
      #2

      Could you be a little more specific? Do you mean the "load() function":http://doc.qt.nokia.com/4.7-snapshot/qwebframe.html#load ?

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        zither
        wrote on last edited by
        #3

        No, I want to set setHtml() function & want to show newly set html on webframe...
        Thanks

        1 Reply Last reply
        0
        • L Offline
          L Offline
          loladiro
          wrote on last edited by
          #4

          Well, AFAIK, setHtml should change the content immediately. If you are looking for a widget (not a frame inside an already exiting Page/Widget), you should use "QWebView":http://doc.qt.nokia.com/4.7-snapshot/qwebview.html

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            zither
            wrote on last edited by
            #5

            Here is code. WebView is abstract of QWebView

            @void WebView::loadFinished()
            {
            page()->mainFrame()->setHtml(newHtml);
            }
            @
            I want to change html after finished loading of that page
            Thanks

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              zither
              wrote on last edited by
              #6

              I found some reason,
              I set view-> setHtml(newHtml);

              They change but, change to original just after finished
              I think that may connect with changeUrl signal but I can't find out..

              Plz help me
              Thanks

              1 Reply Last reply
              0
              • J Offline
                J Offline
                jim_kaiser
                wrote on last edited by
                #7

                Hi zither,

                Could you post the related code of your WebView. Firstly, the setHtml will cause the loadFinished signal to be posted again, causing an infinite loop. I have attached working code of what you want to do.

                @
                #include "mainwindow.h"
                #include "ui_mainwindow.h"

                #include <QtWebKit/QWebView>

                MainWindow::MainWindow(QWidget *parent) :
                QMainWindow(parent),
                ui(new Ui::MainWindow)
                {
                ui->setupUi(this);

                connect(ui->webView, SIGNAL(loadFinished(bool)), this, SLOT(slotloadFinished(bool)));
                
                ui->webView->load(QUrl("http://www.google.com"));
                

                }

                MainWindow::~MainWindow()
                {
                disconnect(ui->webView, 0, this, 0);

                delete ui;
                

                }

                void MainWindow::slotloadFinished(bool okay)
                {
                disconnect(ui->webView, SIGNAL(loadFinished(bool)), this, SLOT(slotloadFinished(bool)));

                ui->webView->setHtml("&lt;html&gt;&lt;body>test&lt;/body&gt;&lt;/html>");
                
                connect(ui->webView, SIGNAL(loadFinished(bool)), this, SLOT(slotloadFinished(bool)));
                

                }
                @

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  jim_kaiser
                  wrote on last edited by
                  #8

                  Instead of the disconnect and connect, you could do this..

                  @
                  void MainWindow::slotloadFinished(bool okay)
                  {
                  ui->webView->blockSignals(true);

                  ui->webView->setHtml("&lt;html&gt;&lt;body>test&lt;/body&gt;&lt;/html>");
                  
                  ui->webView->blockSignals(false);
                  

                  }
                  @

                  1 Reply Last reply
                  0
                  • Z Offline
                    Z Offline
                    zither
                    wrote on last edited by
                    #9

                    It's work.. :)
                    Thanks to all

                    1 Reply Last reply
                    0
                    • L Offline
                      L Offline
                      loladiro
                      wrote on last edited by
                      #10

                      Good to hear that. Also, could you please add [Solved] in front of the title (by editing the first post).

                      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