[Qt]Object::connect



  • hello

    I simplify the code.
    So I want QWebView displays detai loading the page in a QStatuBar
    @
    #include <QApplication>
    #include <QWidget>
    #include <QWebView>
    #include <QVBoxLayout>
    #include <QMainWindow>
    #include <QStatusBar>
    #include <QProgressBar>
    #include <QObject>
    int main(int argc, char* argv[])
    {
    QApplication app(argc,argv);
    QStatusBar *a=new QStatusBar();
    QMainWindow *ongle = new QMainWindow();
    a->setVisible(true);
    QWebView *page=new QWebView();
    page->load(QUrl("http://siteduzero.com"));
    ongle->setCentralWidget(page);
    QObject::connect(page,SIGNAL(statusBarMessage(QString)),a,SLOT(showMessage(QString)));
    ongle->show();

    return app.exec();
    }@
    the problems is that code displays the page without details for exempel chrome when it load a page it display a small bar in the right corner that displai details


  • Moderators

    Hi,

    statusBarMessage is not a loading progress message. It's what a web page can set via javascript windows.status property. Most(all?) of the current browsers don't show this at all (by default). What chrome shows is the url of the currently loaded resource.

    Btw. You've got your variable name wrong - QWebView is not a page. QWebView::page() returns a QWebPage that is a page. QWebView is a widget.



  • thx chris
    if you haven't shown up, I suppose that I will continue trying to solve a problem without solution
    so how do Imake this "the url of the currently loaded resource"



  • Hi, the simplified code you given doesn't work, as your mainWindow don't have a statusbar at all. and the toplevel statusbar which isn't belong to mainWindow isn't shown by you too.



  • hi 1+1=2
    how I fix it and how to do to make the satutbar display information about the page load (the currently loaded resource.)


  • Moderators

    You can add a QStatusBar to your QMainWindow with "setStatusBar":http://qt-project.org/doc/qt-5.1/qtwidgets/qmainwindow.html#setStatusBar or via the designer. Also by default, when you create a new app, you get a .ui form with mainwindow that already has a statusbar and a toolbar.

    Now for monitoring resources. The easiest way is to subclass QNetworkAccessManager and set it on your QWebPage with "setNetworkAccessManager":http://qt-project.org/doc/qt-5.1/qtwebkit/qwebpage.html#setNetworkAccessManager

    In your NAM implementation you override get, post and other types of requests to emit a custom signal like requestedResource(QString url) and then call base implementation.
    Then, in your main window you connect to that custom signal and display the url in the status bar.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.