Results 1 to 4 of 4

Thread: Overriding drawRubberBand()

  1. #1
    Join Date
    Apr 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Overriding drawRubberBand()

    Hi all,

    I am brand new to Qwt and am currently trying to override drawRubberBand() so that I can have a semi-transparent, gray rubberband. My initial inclination was to override drawRubberBand() and set some of the parameters of QPainter (e.g. opacity, brush).

    However, it's not working as I've expected. From initial debugging, it seems the problem is with the updateMask() function conflicting with what I want to do. I noticed that it's a virtual function but don't know if it's possible to override a virtual function of a private inner class.

    Is there a better way to accomplishing my goal of having an semi-transparent, filled rectangle as a rubberband?

    As a related issue, I would also like the rectangle to persist until a new rectangle is selected.

    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: Overriding drawRubberBand()

    My initial inclination was to override drawRubberBand() and set some of the parameters of QPainter (e.g. opacity, brush).
    This should be the right idea - simply set a brush and call drawRubberBand() from the base class. Use your semitransparent brush, when the painter is connected to a widget and use Qt::color1, when it is connected to a QBitmap ( = updateMask ).
    As a related issue, I would also like the rectangle to persist until a new rectangle is selected.
    You need to implement a new type of plot item. Have a look at the RectItem of the navigation example in SVN trunk: http://qwt.svn.sourceforge.net/viewv...02&view=markup. Update + show the RectItem after your picker has selected an area and hide it, when your picker start selecting.

    Uwe

  3. #3
    Join Date
    Apr 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Overriding drawRubberBand()

    For the semitransparent rubber band, what is the best mechanism for determining if the painter is connected to a widget? The only thing I can think of is dynamic casting but that would be slow if called everytime drawRubberBand is called... Or, am I just totally off base?

  4. #4
    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: Overriding drawRubberBand()

    Yes you are: avoiding a dynamic cast is the last thing that is of relevance in this context.

    Uwe

Similar Threads

  1. General question about events overriding
    By mattc in forum Qt Programming
    Replies: 2
    Last Post: 14th September 2009, 15:35
  2. Overriding QListView painting
    By efegea in forum Qt Programming
    Replies: 2
    Last Post: 29th November 2008, 17:16
  3. Overriding shortcuts for QGraphicsItems
    By pherthyl in forum Qt Programming
    Replies: 3
    Last Post: 16th May 2008, 22:47
  4. overriding the QWidget::contextMenuEvent
    By smarinr in forum Qt Programming
    Replies: 1
    Last Post: 9th May 2008, 21:16
  5. overriding the minimise,maximise buttons
    By amulya in forum Qt Programming
    Replies: 6
    Last Post: 24th March 2006, 09:25

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.