Results 1 to 2 of 2

Thread: creating custom curve style

  1. #1
    Join Date
    Oct 2010
    Posts
    58
    Thanks
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default creating custom curve style

    Hi I am having a problem making my own QwtPlotCurve style. I want to make dotted lines like this post http://www.qtcentre.org/threads/2017...ht=dottedlines but I can't figure out how to call my new curve style.

    My question is how do I actually call my style?

    right now I put the built in curve styles into a list of styles like this

    Qt Code:
    1. QwtPlotCurve::CurveStyle Styles[] = { QwtPlotCurve::Lines, QwtPlotCurve::Sticks, QwtPlotCurve::Steps, QwtPlotCurve::Dots};
    2. for( int i = 0; i < 4; i++)
    3. this->Styles[i] = Styles[i];
    To copy to clipboard, switch view to plain text mode 

    am I supposed to add QwtPlotCurve::UserCurve into that list, and if so how do I make sure it calls my reimplemented drawCurve? I think I am missing something basic.

    Another idea that I had was to just call my class when I try to set the style

    Qt Code:
    1. curve->setStyle(dotLines->DottedLines);
    To copy to clipboard, switch view to plain text mode 

    but I get the error 'QwtPlotCurve::setStyle' : cannot convert parameter 1 from 'DotLines::curveStyle' to 'QwtPlotCurve::CurveStyle'

    which confuses me because my class DotLines inherits from QwtPlotCurve


    Qt Code:
    1. class DotLines : public QwtPlotCurve{
    2. public:
    3.  
    4. enum curveStyle
    5. {
    6. DottedLines = QwtPlotCurve::UserCurve + 1000
    7. };
    8.  
    9.  
    10. virtual void drawCurve( QPainter * painter, int style, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const{
    11. if( style < QwtPlotCurve ::UserCurve )
    12. QwtPlotCurve::drawCurve(painter, style, xMap, yMap, canvasRect, from, to );
    13. }else{
    14. /// make dotted lines
    15. }
    16.  
    17. };
    To copy to clipboard, switch view to plain text mode 


    Any Ideas? Thanks

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: creating custom curve style

    Well. this is more a C++ beginner question, than Qwt related. The simple answer is: use casts.

    Uwe

  3. The following user says thank you to Uwe for this useful post:

    kja (16th March 2011)

Similar Threads

  1. creating text following a curve in QT
    By mangeshj in forum Qt Programming
    Replies: 3
    Last Post: 15th January 2011, 11:56
  2. Replies: 0
    Last Post: 4th November 2010, 14:51
  3. Replies: 4
    Last Post: 29th April 2010, 06:11
  4. Creating a style for a button
    By Luc4 in forum Qt Programming
    Replies: 2
    Last Post: 23rd April 2010, 13:16
  5. Replies: 1
    Last Post: 22nd January 2010, 14:34

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.