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