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 draw horizontal horizontal line on QCustomPlot?

How to draw horizontal horizontal line on QCustomPlot?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.6k 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.
  • T Offline
    T Offline
    TheCeylann
    wrote on last edited by
    #1

    I want to add 2 fixed lines horizontally to the chart. I tried the below Code but it adds the line vertically. How can I make it horizontal?

    QCPItemStraightLine *infLine = new QCPItemStraightLine(customPlot);
    infLine->point1->setCoords(2, 0);  // location of point 1 in plot coordinate
    infLine->point2->setCoords(2, 1);  // location of point 2 in plot coordinate
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Fix the coordinates. Twice the same x coordinates will make a vertical line.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      T 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        Fix the coordinates. Twice the same x coordinates will make a vertical line.

        T Offline
        T Offline
        TheCeylann
        wrote on last edited by
        #3

        @SGaist Thank you. It's worked, Can I ask how can I set color for this?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          From a quick look at the class documentation: setPen.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2

          • Login

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