Class NewQCPLineEnding : public QCPLineEnding { Q_GADGET public: enum EndingStyle {esSun = 100, esMoon, esStar}; NewQCPLineEnding(); NewQCPLineEnding(EndingStyle style, double width=8, double length=10, bool inverted=false); EndingStyle style() const { return mStyle; } void draw(QCPPainter *painter, const QCPVector2D &pos, const QCPVector2D &dir) const { ... case esSun: ... break; case esMoon: ... break; case esStar: ... break; ... } protected: EndingStyle mStyle; }; class NewQCPItemLine : public QCPItemLine { Q_OBJECT public: explicit NewQCPItemLine(QCustomPlot *parentPlot); virtual ~NewQCPItemLine() Q_DECL_OVERRIDE {} void setHead(const NewQCPLineEnding & head) { mHead = head;} void setTail(const NewQCPLineEnding & tail) { mTail = tail;} protected: WCPLineEnding mHead,mTail; virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE { if (mTail.style() != static_cast<NewQCPLineEnding::EndingStyle>(QCPLineEnding::esNone)) mTail.draw(painter, endVec, endVec-startVec); if (mHead.style() != static_cast<NewQCPLineEnding::EndingStyle>(QCPLineEnding::esNone)) mHead.draw(painter, endVec, endVec-startVec); } }; auto sun = new NewQCPItemLine(plot); sun->setHead(NewQCPLineEnding::esSun);
I've tried it. Is that correct?