Reputation: 11651
I currently have a QCustomPlot and I would like to show a QtoolTip on mouseover the component. Here is what I am using. This is my slot.
void CustomPlot::DisplayPlotValue(QMouseEvent* val)
{
QToolTip::showText(val->pos(), "A tool tip");
}
However the tool tip aappears in the wrong cordinates (its infact out of the form that has my component) . Any suggestion on what i might be doing wrong ?
Upvotes: 1
Views: 513
Reputation: 3801
Use QWidget::mapToGlobal to map coordinates relative to a widget to global coordinates, which are relative to the whole screen:
QToolTip::showText(widget->mapToGlobal(val->pos()), "A tool tip");
where widget is your QWidget.
Upvotes: 1
Reputation: 73081
Try this instead:
QToolTip::showText(val->globalPos(), "A tool tip");
Upvotes: 2