Hi.
How I can determine which webview widget emitted linkClicked signal?
I have tabWidget with WebView *wv = new WebView() create after triggered action in new tabBar. And i don't know which widget emitted signal
Please help
Maston
Hi.
How I can determine which webview widget emitted linkClicked signal?
I have tabWidget with WebView *wv = new WebView() create after triggered action in new tabBar. And i don't know which widget emitted signal
Please help
Maston
You can use QObject::sender() but that breaks the oo design.
You have to cast sender() to QWebView. See qobject_cast.
it's working but sender is always MainWindow.
i have something like this :
Qt Code:
and slot: { . . . }To copy to clipboard, switch view to plain text mode
nwb is QWebView. That's problem with sender? slot in MainWindow class?
Is it possible to use a signal mapper?
signal mapper is declared in constructor right? my WebView is created by QTCreator ( ui_mainwindow.h ) .so i don't have access to constructor class.
Or I don't know how to do it... yetSome advice?
You define the mapper in your main window.
Then you connect the linkClicked signal to the mapper map() slot.
You set a mapping, like the pointer to the webview
Then you connect the mapped signal to your custom slot having instant access to the calling webview.
thank You...do You know how change argumets in mapped() signal? i have this:
QObject::connect: Incompatible sender/receiver arguments
QSignalMapper::mapped(QObject*) --> MainWindow::link_click(QUrl)
I'm sorry, I'm an idiot.
A signal mapper will not work here since you can only use signals with no parameters.
Since I'm being stupid, here's another stupid idea ;-)
For each webview, connect to a unique slot.
This works if you have a small static amount of webviews. Not for a dynamic amount.
But, using sender() should not return the main window.
Qt Code:
QWebPage *theWebPageWhoSentTheSignal = qobject_cast<QWebPage *>(sender()); If (theWebPageWhoSentTheSignal ) { ... }To copy to clipboard, switch view to plain text mode
it's exactly what i wrote earlierand returns MainWindow.
How for example chrome know which webview linkclicked signal was emitted? it is possiblei am seeking further
thank You anyway
![]()
Bookmarks