Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to make point's text lable adjust with scale of x-axis and y-axis in QCustomPlot?
Qt 6.11 is out! See what's new in the release blog

How to make point's text lable adjust with scale of x-axis and y-axis in QCustomPlot?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 949 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hitbuyi
    wrote on last edited by hitbuyi
    #1

    x[0] = 10;
    y[0] = 50;

    x_offset = 0.7;
    y_offset = 1.0;
    QCPItemText *textLabel = new QCPItemText(ui->widget);
    textLabel->position->setCoords(x[0]- x_offset, y[0] + y_offset); // place position at center/top of axis rect
    textLabel->setColor(Qt::white);
    QString str;
    str.sprintf("%d", 10);
    textLabel->setText(str);
    textLabel->setFont(QFont(font().family(), 8)); // make font a bit larger

    The problem is , if x-axis range is (-20,20), y-axis range is (-50,100), the text lable is near the point(x[0],y[0]) properly. when x-axis range is set to (-200,200), y-axis range is set to (-500,500), the lable is merge with point(x[0],y[0]) because of large scale, what I want is lable's postion is near the point from the eye of view
    how to solve this problem? for this kind of problem,MATLAB solved it perfectly, point and its lable are
    displayed rightly under different scale of x-axis and y-axis

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      If you don't get any answers here, try the QCustomPlot forum.
      https://www.qcustomplot.com/index.php/support/forum

      QCustomPlot is not an official Qt module so you have to be lucky that someone knows here.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved