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. QWeView is empty when going to internal target location
Forum Updated to NodeBB v4.3 + New Features

QWeView is empty when going to internal target location

Scheduled Pinned Locked Moved Unsolved Qt WebKit
1 Posts 1 Posters 511 Views
  • 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.
  • M Offline
    M Offline
    MVadim
    wrote on last edited by
    #1

    Hello everyone. I'm confused. When i go to internal target location then window title QWebView will be empty.
    I don't understand.

    Code:

    **header:**
    
    #include <QWidget>
    #include <QWebPage>
    #include <QWebView>
    class MainWindow : public QWidget
    {
    	Q_OBJECT
    
    public:
    	explicit MainWindow(QUrl url, QWidget *parent = 0);
    
    private slots:
    	void titleChanged(QString);
    private:
    	QWebView webView;
    	QWebPage page;
    };
    **cpp:**
    
    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QWebFrame>
    #include <QPainter>
    #include <QPixmap>
    #include <QPushButton>
    #include <QDebug>
    
    MainWindow::MainWindow(QUrl url, QWidget *parent) :
    	QWidget(parent)
    {
    	page.mainFrame()->load(url);
    	connect(&page, SIGNAL(loadFinished(bool)),
    		this, SLOT(showPage()));
    	connect(page.mainFrame(), SIGNAL(titleChanged(QString)), this, SLOT(titleChanged(QString)));
    	webView.setPage(&page);
    	webView.show();
    }
    void MainWindow::titleChanged(QString title)
    {
    	QString old_title = page.mainFrame()->title();
    	qDebug() << "\nOld title " << old_title;
    	qDebug() << "\nNew title " << title;
    	webView.setWindowTitle(title);
    }
    
    
    

    For example:

    1. On link text we can see "Contens" if window is small.
    2. Next, open "Contens", and click on first internal target location ("Public types"), we are going other place in current page.
    3. Then emit titleChanged which it is empty. Why???
      Explain please.
    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