I am trying to use an image as a tooltip on a QLabel. I am following the method described here : Use a picture or image in a QToolTip
But I get an automatic margin around that image, which I would like to remove. By making the border apparent in stylesheet, and setting the tooltip background color, we can check that the additional margin is not part of the image, but is inside the border. Yet explicitely setting padding at "0px" doesn't remove it either.
Here is a minimal example:
#include "qapplication.h"
#include <QLabel>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QLabel hello("Hello world!", 0) ;
hello.resize(200, 100);
hello.setStyleSheet("QToolTip { padding: 0px; border: 2px solid green; background: red;}");
QString html = QString("<img src='test.png'>");
hello.setToolTip(html);
hello.show();
return a.exec();
}
And here is what I get from it :
The image is correct. The border follows the stylesheet, but I don't know where that red area comes from. How to get rid of this "margin"? Is this a QTooltip bug ?
It somewhat looks like the bug described here, but I am using Qt5.12.5, where it should be resolved : https://bugreports.qt.io/browse/QTBUG-59119
Edit: I'm on windows. The image is 482x482px large. I had someone try it on Linux, and that unwanted margin was also there, but much smaller.