Results 1 to 16 of 16

Thread: Tooltip to QwtSymbol ???

  1. #1
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Tooltip to QwtSymbol ???

    Hello everyone,

    I have a QwtSymbol on plot and i want to display like a tool-tip for each symbol i have on the curve, when i click on the symbol.
    so how can i attache like a tool-tip to display the info i need ??

    Thanks

  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: Tooltip to QwtSymbol ???

    You can use QwtPlotPicker overloading trackerText(). How to identify which click is a match of which symbol and how to connect a match to the information you want to display is up the the application code.

    Maybe the ( slow ! ) implementation of CanvasPicker::select in the event_filter example is something you can use. When the symbols are from curves with an ordered set of points you might want to use qwtUpperSampleIndex you can find in qwt_series_data.h in SVN trunk.

    Uwe

  3. #3
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Tooltip to QwtSymbol ???

    Thanks,

    Regarding how i identify the symbols, i used the event_filter example.
    but there is an issue i faced which, when i have other curve that does NOT have symbols, and i click close to one of its points the application crashes. i know because it expects a symbol and didn't find it, but how can i fix this issue, so what would be my if statements to check if the curve has a symbol or not ?? hope you got what i am trying to explain.

    how i connect the information to the symbol, I save the information i want to display with each symbol in the same order i draw the symbol an with that the symbol index is my index for the information.
    thanks

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Tooltip to QwtSymbol ???

    Quote Originally Posted by jesse_mark View Post
    so what would be my if statements to check if the curve has a symbol or not ?? hope you got what i am trying to explain.
    Qt Code:
    1. if(curve->symbol()) {
    2. // curve has a symbol
    3. } else {
    4. // curve doesn't have a symbol
    5. }
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Tooltip to QwtSymbol ???

    Yeah i tried this and its crashed as well,

    so what i did is if (d_selectedCurve->style()== QwtPlotCurve::Lines) as in my case the curves that has symbols are a noline style. this worked for me.

    Thank you so much Wysota

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Tooltip to QwtSymbol ???

    Quote Originally Posted by jesse_mark View Post
    Yeah i tried this and its crashed as well,
    If it did then "curve" was pointing to an invalid object.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Tooltip to QwtSymbol ???

    but this method only got called when we get a point on a curve with its index.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Tooltip to QwtSymbol ???

    But it is you who initializes this variable. Maybe you did it incorrectly. Did you use d_selectedCurve->symbol() or something else?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Tooltip to QwtSymbol ???

    yes i did used it. i almost used the same code in the example i only added thing i need. but the method and detecting the symbol is same as the example.
    so maybe u can just add a curve with no symbols in the example and see that.

  10. #10
    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: Tooltip to QwtSymbol ???

    I can only repeat myself: use a combination of QwtPlotPicker and QwtPlotCurve::closestPoint() ( or something faster depending on the characteristics of your curve ).

    Copying code from an unrelated example instead of trying to understand what needs to be done is nothing but a waste of time.

    Uwe

  11. #11
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Tooltip to QwtSymbol ???

    My main problem was not detection the symbols on the curve or how to related the information to the selected symbol, and this is clear from my question which is tooltip for symbols.
    you suggested this example too, in "CanvasPicker::select in the event_filter example is something you can use".

    I do have the information displayed in a fixed label when i click the symbol. but I was wording if there a way to display a kinda tool-tip to symbols.
    you suggested overloading trackerText(),

    I was thinking of using QwtPlotMarker
    i tired something like :


    Qt Code:
    1. QwtText *t = new QwtText;
    2.  
    3. t->setText("Test");
    4. m->setLabel(*t);
    5. m->attach(myplot);
    6. m->setAxes(4000,1000);
    To copy to clipboard, switch view to plain text mode 
    but the text keep showing on (0,0) coordinates. I do not know what is the wrong im doing.
    or how i show the marker in the position/coordinates I want to.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Tooltip to QwtSymbol ???

    Quote Originally Posted by jesse_mark View Post
    I do have the information displayed in a fixed label when i click the symbol. but I was wording if there a way to display a kinda tool-tip to symbols.
    you suggested overloading trackerText(),
    I'm doing something like this. I have a plot picker set up with tracking machine that keeps track of the position of the cursor in plot coordinate space. Then I'm handling help events on the plot to show a tooltip based on the data from the picker if the closest point in the curve is close enough to the cursor (i.e. manhattan length <= some constant in pixels).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Tooltip to QwtSymbol ???

    Quote Originally Posted by wysota View Post
    Then I'm handling help events on the plot to show a tooltip based on the data from the picker
    Can you please explain more...
    what are the help events ??
    The tooltip you are showing ?? are you using Tracker Text and qwttext ?? or what exactly u r using ??

    the other thing how can i show the marker in plot coordinate, if you saw the example i put in the previous reply ??

    Thank you soo much.

  14. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Tooltip to QwtSymbol ???

    Quote Originally Posted by jesse_mark View Post
    what are the help events ??
    QHelpEvent
    The tooltip you are showing ?? are you using Tracker Text and qwttext ?? or what exactly u r using ??
    QToolTip::showText()
    the other thing how can i show the marker in plot coordinate, if you saw the example i put in the previous reply ??
    If you use a real marker then the downside is that the plot has to be replot each time you want to change the marker position (provided you don't want to mess up with the way the plot is rendered). A better way is to draw the marker on a separate layer (e.g. using an overlay widget) which doesn't influence the plot itself.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  15. #15
    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: Tooltip to QwtSymbol ???

    Quote Originally Posted by wysota View Post
    I'm doing something like this. I have a plot picker set up with tracking machine that keeps track of the position of the cursor in plot coordinate space. Then I'm handling help events on the plot to show a tooltip based on the data from the picker if the closest point in the curve is close enough to the cursor (i.e. manhattan length <= some constant in pixels).
    Instead of using a tooltip it is also possible to overload trackerText and simply return an empty text, when the position is too far away and a valid text otherwise. As a QwtText might have a background and a frame it doesn't look too different from a tooltip.

    For a combination of QwtPickerClickPointMachine and the tracker mode set to QwtPicker::ActiveOnly the trackerText() hook will only be called for mouse clicks - if this is what is requested.

    Uwe

    PS: sooner or later I will offer an implementation of some spatial ordering ( f.e. a quadtree ) to speed up this use case for curves with many points

  16. #16
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Tooltip to QwtSymbol ???

    Quote Originally Posted by Uwe View Post
    As a QwtText might have a background and a frame it doesn't look too different from a tooltip.
    I'd say this depends on the system theme. Besides, I wanted a tooltip, with standard delay of showing it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 4
    Last Post: 29th March 2011, 21:33
  2. Replies: 1
    Last Post: 27th January 2011, 11:06
  3. Alignment of QwtSymbol
    By FelixB in forum Qwt
    Replies: 2
    Last Post: 11th January 2011, 09:40
  4. Tooltip in Qwt
    By Ankitha Varsha in forum Qwt
    Replies: 5
    Last Post: 8th December 2009, 13:07
  5. QwtSymbol highlighting?
    By shud in forum Qwt
    Replies: 1
    Last Post: 2nd October 2009, 22:42

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.