Qt C++ WebKit windowCloseRequested Signal
I am trying to connect QWebpage::windowCloseRequested() to a slot that just prints out a debug message. When I call window.close(); in JavaScript it doesn't bubble the signal up or call the slot...
connect(webView->page(), SIGNAL(windowCloseRequested()),this, SLOT(windowCloseRequested()));
The slot is setup, it is in my window.h file as a slot like this:
public slots:
void windowCloseRequested();
And the function is defined as:
void MyWindow::windowCloseRequested(){
qDebug() << "I was called";
}
When I compile, there are no errors, there were before saying I had开发者_运维知识库 the slots wrong, I figured that part out, no more error, but now when I click a link, or call window.close() with javascript in a loaded webpage, it doesn't do anything. If I manually call the function, it prints out the debug message.
Any pointers, or help/solutions would be appreciated. Note, this code above is based on the Tabwidget.cpp code for a browser example. It's the best reference I could find.
Attaching an onclick to an <a>
tag is ... questionable. Use a span, and blammo, it works. This is why you should take breaks when coding, or else you make really dumb mistakes that waste time.
精彩评论