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?
Forum Updated to NodeBB v4.3 + New Features

How to draw horizontal horizontal line on QCustomPlot?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.3k 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 27 Sept 2022, 16:36 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
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 27 Sept 2022, 16:57 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 27 Sept 2022, 18:14
      1
      • S SGaist
        27 Sept 2022, 16:57

        Hi,

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

        T Offline
        T Offline
        TheCeylann
        wrote on 27 Sept 2022, 18:14 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
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 27 Sept 2022, 19:02 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

          1/4

          27 Sept 2022, 16:36

          • Login

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