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 modify the color and width of a specific grid line in QChartView
Forum Update on Monday, May 27th 2025

How to modify the color and width of a specific grid line in QChartView

Scheduled Pinned Locked Moved Solved General and Desktop
qchartview
2 Posts 1 Posters 1.0k Views
  • 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.
  • A Offline
    A Offline
    a364858
    wrote on last edited by
    #1

    I want to highlight the only one grid line.

    I tried to subclass QChartView and reimplemented paintEvent(). And then I drew a line in the same place as the gird line.

    But it covers the points on QScatterSeries.

    What i expect is that the points on QScatterSeries covers the new line, or the color and width of a specific grid line can be modified directly.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      a364858
      wrote on last edited by
      #2

      Drawing a QGraphicsRectItem to cover the grid line is the solution.

      QChart * pChart = new QChart(nullptr);
      // add axises, series, points
      QGraphicsRectItem * pItem = new QGraphicsRectItem(0, 0, 0, 0, pChart->graphicsItem());
      pItem->setPen(QPen(Qt::red));
      pItem->setBrush(QPen(Qt::red));
      pItem->setZValue(3); // points on QScatterSeries covers  this item and this item covers grid lines
      pItem->setRect(/*   */); // to cover the gird line
      
      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