Tooltip in a point of a graph
-
Hi, I want to put a toolTip in a point of a graph...I tried:
double x_c = ui->widget->xAxis->coordToPixel(x_widg);
double y_c = ui->widget->yAxis->coordToPixel(y_widg);
QPoint coord;
y_c = coord.y();
x_c= coord.x();QToolTip::showText(coord, line9);
x_widg and y_widg are the coordinates of the point...I tried this way but without solution..
-
Hi, I want to put a toolTip in a point of a graph...I tried:
double x_c = ui->widget->xAxis->coordToPixel(x_widg);
double y_c = ui->widget->yAxis->coordToPixel(y_widg);
QPoint coord;
y_c = coord.y();
x_c= coord.x();QToolTip::showText(coord, line9);
x_widg and y_widg are the coordinates of the point...I tried this way but without solution..
@vale88 said in Tooltip in a point of a graph:
QPoint coord;
y_c = coord.y();
x_c= coord.x();These two lines are completely useless because https://doc.qt.io/qt-5/qpoint.html#QPoint, so you set x_c, y_c and coord to 0.
It should actually bedouble x_c = ui->widget->xAxis->coordToPixel(x_widg); double y_c = ui->widget->yAxis->coordToPixel(y_widg); QPoint coord(x_c, y_c); QToolTip::showText(coord, line9);
-
@vale88 said in Tooltip in a point of a graph:
QPoint coord;
y_c = coord.y();
x_c= coord.x();These two lines are completely useless because https://doc.qt.io/qt-5/qpoint.html#QPoint, so you set x_c, y_c and coord to 0.
It should actually bedouble x_c = ui->widget->xAxis->coordToPixel(x_widg); double y_c = ui->widget->yAxis->coordToPixel(y_widg); QPoint coord(x_c, y_c); QToolTip::showText(coord, line9);
@jsulm There are two problems..when I have two screens and I put the graph on the second screen the tip is on the first screen..and when I click and the tip compares I have a refresh..a black shadow..anyway thanks for the help
-
Are you looking for something like this? https://doc.qt.io/qt-5/qtcharts-callout-example.html
-
Are you looking for something like this? https://doc.qt.io/qt-5/qtcharts-callout-example.html
@VRonin I wrote
QPoint coord(ui->widget->mapToGlobal(QPoint(x_widg,y_widg)));
QToolTip::showText(coord,line9);
ui->widget_2->graph(4)->setData(qv_x2,qv_y2);but I obtain the point (0,0) on the MainWindow
-
@VRonin I wrote
QPoint coord(ui->widget->mapToGlobal(QPoint(x_widg,y_widg)));
QToolTip::showText(coord,line9);
ui->widget_2->graph(4)->setData(qv_x2,qv_y2);but I obtain the point (0,0) on the MainWindow
@vale88 said in Tooltip in a point of a graph:
x_widg,y_widg
what values do they have and how did you get them?
-
@vale88 said in Tooltip in a point of a graph:
x_widg,y_widg
what values do they have and how did you get them?
@jsulm x_widg and y_widg are right on the graph..then I havo to obtain this coordinates on the MainWindow to be global..but in this way the tip is on the top left of the screen and not on the coordinates (x_widg, y_widg)