Results 1 to 2 of 2

Thread: Different Colored Rectangles in QwtPlotPicker

  1. #1
    Join Date
    Jul 2009
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Different Colored Rectangles in QwtPlotPicker

    Hi everyone,

    I would like to have one QwtPlotPicker object attached to my plot that allows me to select a rectangle of color A (for instance, green) using the left mouse button, while also being able to select a rectangle of color B (red) using the right mouse button.

    Currently, I am attaching the mouse buttons to patterns like this:

    Qt Code:
    1. signalPicker-> new MySignalPicker( canvas() );
    2. signalPicker->setSelectionFlags( QwtPicker::RectSelection | QwtPicker::DragSelection );
    3. signalPicker->setRubberBand( QwtPicker::RectRubberBand );
    4. signalPicker->setMousePattern( QwtEventPattern::MouseSelect1, Qt::LeftButton );
    5. signalPicker->setMousePattern( QwtEventPattern::MouseSelect2, Qt::RightButton );
    To copy to clipboard, switch view to plain text mode 

    Also, in my inherited class, MySignalPicker, I have reimplemented the widgetMousePressEvent() function:

    Qt Code:
    1. virtual void widgetMousePressEvent( QMouseEvent* me )
    2. {
    3. if( mouseMatch( MouseSelect1, me ) )
    4. {
    5. setRubberBandPen( QColor( Qt::green ) );
    6. }
    7. else if( mouseMatch( MouseSelect2, me ) )
    8. {
    9. setRubberBandPen( QColor( Qt::red ) );
    10. }
    11. transition( ( QEvent* )me );
    12. }
    To copy to clipboard, switch view to plain text mode 

    Hoever, it seems like only MouseSelect1 is able to draw rectangles. I've been trying to look through the source code, but I haven't had any luck yet finding out where/why only MouseSelect1 can draw rectangles.

    Any help would be appreciated.

    Thanks in advance,
    Chris

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

    Default Re: Different Colored Rectangles in QwtPlotPicker

    Use 2 pickers with different pens.

    Uwe

Similar Threads

  1. Colored cursor
    By maverick_pol in forum Qt Programming
    Replies: 4
    Last Post: 15th May 2008, 13:16
  2. editable rectangles
    By parmar ranjit in forum Qt Programming
    Replies: 3
    Last Post: 20th February 2008, 10:59
  3. Colored Buttons
    By Walsi in forum Newbie
    Replies: 33
    Last Post: 8th December 2007, 13:58
  4. Rendering rectangles speed issue
    By macbeth in forum Qt Programming
    Replies: 11
    Last Post: 15th March 2007, 02:30
  5. Replies: 4
    Last Post: 17th January 2006, 18:46

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.