Results 1 to 3 of 3

Thread: reimplement drawTracker issue in my picker class derived from QwtPlotPicker

  1. #1
    Join Date
    Sep 2011
    Posts
    30
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default reimplement drawTracker issue in my picker class derived from QwtPlotPicker

    Hi,
    I use QwtPlotPicker to track user's moving by Left/Right key in plot. I subclass QwtPlotPicker and reimplement trackerRect and drawTracker method to show one vertical dotline in plot, I got it but the vertical dotline is very short and not my expected. please see follow code and result. I need the vertical dotline to be as from bottom to top, anyone can give some suggestions? thanks.

    Qt Code:
    1. QRect CsmPicker::trackerRect(const QFont &) const
    2. {
    3. QPoint p = trackerPosition();
    4. const QwtPlot *pickerPlot = plot();
    5. const QwtScaleDiv *scaleDiv = pickerPlot->axisScaleDiv(QwtPlot::yLeft);
    6. int min = scaleDiv->lowerBound();
    7. int max = scaleDiv->upperBound();
    8.  
    9. QRect rect(0, min, 100, (max-min));
    10. rect.moveTo(p.x(), min);
    11.  
    12. return rect;
    13. }
    14.  
    15. void CsmPicker::drawTracker(QPainter *painter) const
    16. {
    17. QPoint p = trackerPosition();
    18. const QwtPlot *pickerPlot = plot();
    19. const QwtScaleDiv *scaleDiv = pickerPlot->axisScaleDiv(QwtPlot::yLeft);
    20. int min = scaleDiv->lowerBound() + 5;
    21. int max = scaleDiv->upperBound() - 5;
    22.  
    23. QPen pen(QColor(180, 180, 180));
    24. pen.setStyle(Qt::DotLine);
    25. painter->setPen(pen);
    26.  
    27. QFont font = painter->font();
    28. painter->setClipRect(trackerRect(font));
    29. painter->drawLine(p.x(), min, p.x(), max);
    30.  
    31. painter->drawText(p.x(), p.y(), "Test");
    32. if (p.x() < 0) p.setX(0);
    33. emit mouseMoving(p);
    34. }
    To copy to clipboard, switch view to plain text mode 

    Test.png

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

    Default Re: reimplement drawTracker issue in my picker class derived from QwtPlotPicker

    What about using QwtPicker::VLineRubberBand ?

    Uwe

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

    josentop (9th February 2012)

  4. #3
    Join Date
    Sep 2011
    Posts
    30
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: reimplement drawTracker issue in my picker class derived from QwtPlotPicker

    thanks for your reply. rubberBand only for stateMachine points selection mode, but in my case, it is mouse tracking mode.


    Added after 31 minutes:


    It is fixed using QwtPicker::VLineRubberBand and set QwtPickerMachine to QwtPickerTrackerMachine. thanks.
    Last edited by josentop; 9th February 2012 at 01:17.

Similar Threads

  1. QwtPlot derived class
    By Marco Trapanese in forum Qwt
    Replies: 15
    Last Post: 4th December 2012, 10:05
  2. Replies: 2
    Last Post: 31st July 2011, 09:51
  3. Replies: 3
    Last Post: 27th November 2006, 09:56
  4. rtti() of derived class
    By quickNitin in forum Newbie
    Replies: 4
    Last Post: 8th October 2006, 14:20
  5. Signal/slot looking in base class, not derived class
    By georgie in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2006, 07:36

Tags for this Thread

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.