Problem with using more than one QWebInspector and QWebPage



  • There is QWebPage (#1) with the connected QWebInspector. I open one more QWebPage (#2) (also with the connected QWebInspector). In the code of #1 the operator 'debugger' in js-code is right after the operator 'open a window'. Also there is the operator 'debugger' in the beginning of a script-tag. As result only one debugger was activated. If we have one debugger only either in #1 or #2 code than QWebInspector reacts adequately to both debuggers.
    Perhaps the reason is we use one ScriptDebuggerServer for all WebInspectors?
    Is there a way to set up a few QWebPage with QWebInspector connected to each QWebPag to work correctly?
    I use 4.7.4 MSVC qt library and msvc IDE. Also I commented the code of ::hideEvent in QWebInspector for Inspector doesn't disconnect from the scrypt.
    @
    class QBrowseWnd : public QWebView, protected QScriptable
    {
    Q_OBJECT
    QBrowseWnd(QWidget* parent) : QWebView(parent)
    {
    Initialize();
    }
    void Initialize()
    {
    QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
    QMyWebPage* myWp = safe_new QMyWebPage(this);
    setPage(myWp);

    QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);
    QWidgetFactory* pMyFactory = safe_new QWidgetFactory(this);
    page()->setPluginFactory(pMyFactory);

    bool fres = QObject::connect(page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(ReloadJSObject()));
    page()->mainFrame()->addToJavaScriptWindowObject("external", this);
    }

    Q_INVOKABLE QVariant navigate(QString sUrl)
    {
    m_sUrl = sUrl;
    bool res = QObject::connect(this, SIGNAL(LoadContent()), this, SLOT(AutoLoadQ()), Qt::QueuedConnection);
    emit LoadContent();
    }

    void AutoLoadQ()
    {
    ShowInspector();
    HideInspector();
    disconnect(this, SLOT(AutoLoadQ()));
    load(m_sUrl);
    }

    void QBrowseWnd::ShowInspector()
    {
    QEventLoop el;
    while(true)
    {
    bool fevent = el.processEvents();
    if(!fevent) break;
    }

    QMyWebPage* p = dynamic_cast<QMyWebPage*>(page());
    if(p) p->ShowInspector();

    while(true)
    {
    bool fevent = el.processEvents();
    if(!fevent) break;
    }
    }

    void HideInspector()
    {
    QMyWebPage* p = dynamic_cast<QMyWebPage*>(page());
    if(p) p->HideInspector();

    QEventLoop el;
    while(true)
    {
    bool fevent = el.processEvents();
    if(!fevent) break;
    }
    }
    signals:
    void LoadContent();

    protected slots:
    void AutoLoadQ();
    }

    class QMyWebPage : public QWebPage
    {
    Q_OBJECT
    protected:
    typedef QSharedPointer<QWebInspector> TInspectorPtr;
    TInspectorPtr m_pInspector;
    public:
    QMyWebPage::QMyWebPage( QObject * parent /= 0/ ) : QWebPage(parent)
    {
    m_pInspector = TInspectorPtr(safe_new QWebInspector());
    m_pInspector->setPage(this);
    }

    void QMyWebPage::ShowInspector()
    {
    if(!m_pInspector->isVisible()) m_pInspector->setVisible(true);
    if(!m_pInspector->isActiveWindow()) m_pInspector->activateWindow();
    }

    void QMyWebPage::HideInspector()
    {
    m_pInspector->setVisible(false);
    }
    }
    @


Log in to reply
 

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