Results 1 to 3 of 3

Thread: PlotPicker: TrackerText Position

  1. #1
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default PlotPicker: TrackerText Position

    Hi,

    I'd like to change the position of the trackerText from Top/Right to Bottom/Left. Is there a possibility to do that? I already have my own subclass where I set the trackerText. I tried to override "drawTracker(QPainter*)" and "trackerRect(const QFont&)", but that did not work. The position did not change - instead it disappeared sometimes. I think the problem is, that "trackerRect()" is not declared virtual...

    is there a better way than copying almost each line from qwt_picker.h?

    thanks!
    Felix

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

    Default Re: PlotPicker: TrackerText Position

    Overloading drawTracker is the correct idea. Start with this code:

    Qt Code:
    1. void YourPicker::drawTracker( QPainter *painter ) const
    2. {
    3. const QRect textRect = trackerRect( painter->font() );
    4. if ( !textRect.isEmpty() )
    5. {
    6. QwtText label = trackerText( trackerPosition() );
    7. if ( !label.isEmpty() )
    8. label.draw( painter, textRect );
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 

    Uwe

    PS: QwtPicker::trackerRect is changed to virtual in SVN trunk

  3. #3
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: PlotPicker: TrackerText Position

    Quote Originally Posted by Uwe View Post
    PS: QwtPicker::trackerRect is changed to virtual in SVN trunk
    thank you! when I have time, I'll convert my application to Qwt 6
    I tried to move the resulting rect - but now the Label is disappeared completely.
    Qt Code:
    1. void YourPicker::drawTracker( QPainter *painter ) const
    2. {
    3. QRect textRect = trackerRect( painter->font() ); // removed "const"
    4. textRect.moveTopLeft(QPoint(100,100)); // new line
    5. if ( !textRect.isEmpty() )
    6. {
    7. QwtText label = trackerText( trackerPosition() );
    8. if ( !label.isEmpty() )
    9. label.draw( painter, textRect );
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

    The reason I'm doing this is: In my plot I have a scrollzoomer with scrollbars set to "AlwaysOn" and "AttachedToScales" (they are attached to xTop and yRight). When I move the mouse close to one of the scrollbars, the trackertext is painted on the scrollbar (this does not happen if scrollbar is "AsNeeded" - in this case the trackertext is painted "under" the scrollbar, so it is not visible). When you now move the mouse parallel to the scrollbar, parts of the old trackertext label remain where they were. unfortunately I can't make a screenshot - when I press a button, the scrollbar gets repainted.

Similar Threads

  1. Overlaoding trackerText to show dates
    By Carlton in forum Qwt
    Replies: 1
    Last Post: 4th November 2010, 01:38
  2. X and Y position of QWidget
    By bear101 in forum Qt Programming
    Replies: 1
    Last Post: 22nd May 2009, 23:27
  3. How to get the mouse's position
    By sophister in forum Qt Programming
    Replies: 2
    Last Post: 30th April 2009, 06:07
  4. Replies: 1
    Last Post: 25th July 2008, 08:38
  5. set Position
    By mickey in forum Newbie
    Replies: 3
    Last Post: 17th June 2006, 21:30

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.