WebInspector is network based. You will need to get the first and only child inspector, this will be a QWebView.
Like:
QList<QWidget*> list = inspector.findChildren<QWidget *>(); QWebView* wv =(QWebView*) list.at(0);
Then connect to the javaScriptWindowObjectCleared signal of this view, and in the connected slot, execute javascript. For this you need an object. I called it someObject for example
QObject::connect( wv->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), someObject, SLOT(openNetworkTab()) );
add a slot to someObject class:
void openNetworkTab(){ wv->page()->mainFrame()->evaluateJavaScript("document.addEventListener('DOMContentLoaded',function(){setTimeout(function(){document.querySelector('.toolbar-item.network').click()},200);});"); }
Delay 200 only to wait for all event bindings to initialize until the button is clicked
All classes of the inspector tab are listed here, just in case: .elements, .resources, .net, .scripts, .timeline, .profiles, .audits, .console
source share