@@ -67,6 +67,7 @@ void QgsMapTip::showMapTip( QgsMapLayer *pLayer,
67
67
mWebView ->page ()->setLinkDelegationPolicy ( QWebPage::DelegateAllLinks );// Handle link clicks by yourself
68
68
mWebView ->setContextMenuPolicy ( Qt::NoContextMenu ); // No context menu is allowed if you don't need it
69
69
connect ( mWebView , &QWebView::linkClicked, this , &QgsMapTip::onLinkClicked );
70
+ connect ( mWebView , &QWebView::loadFinished, this , [ = ]( bool ) { resizeContent (); } );
70
71
#endif
71
72
72
73
mWebView ->page ()->settings ()->setAttribute (
@@ -135,22 +136,29 @@ void QgsMapTip::showMapTip( QgsMapLayer *pLayer,
135
136
mWidget ->show ();
136
137
137
138
#if WITH_QTWEBKIT
139
+ resizeContent ();
140
+ #endif
141
+ }
142
+
143
+ void QgsMapTip::resizeContent ()
144
+ {
145
+ // Get the content size
146
+ QWebElement container = mWebView ->page ()->mainFrame ()->findFirstElement (
147
+ QStringLiteral ( " #QgsWebViewContainer" ) );
148
+ int width = container.geometry ().width ();
149
+ int height = container.geometry ().height ();
138
150
int scrollbarWidth = mWebView ->page ()->mainFrame ()->scrollBarGeometry (
139
151
Qt::Vertical ).width ();
140
152
int scrollbarHeight = mWebView ->page ()->mainFrame ()->scrollBarGeometry (
141
153
Qt::Horizontal ).height ();
142
154
143
155
if ( scrollbarWidth > 0 || scrollbarHeight > 0 )
144
156
{
145
- // Get the content size
146
- QWebElement container = mWebView ->page ()->mainFrame ()->findFirstElement (
147
- QStringLiteral ( " #QgsWebViewContainer" ) );
148
- int width = container.geometry ().width () + 5 + scrollbarWidth;
149
- int height = container.geometry ().height () + 5 + scrollbarHeight;
150
-
151
- mWidget ->resize ( width, height );
157
+ width += 5 + scrollbarWidth;
158
+ height += 5 + scrollbarHeight;
152
159
}
153
- #endif
160
+
161
+ mWidget ->resize ( width, height );
154
162
}
155
163
156
164
void QgsMapTip::clear ( QgsMapCanvas * )
0 commit comments