Overloaded QwtPlotPicker::trackerText but no text near mouse pointer

Hi,
I have overloaded QwtPlotPicker::trackerText for showing only Y-values beside
mouse pointer (tracking), but the result is not text at all; here is my code:

const int Size = 12;

double xval[Size] = {1,2,3,4,5,6,7,8,9,10,11,12};
double yval[Size] = {3,4,2,6,5,6,6,3,2,4,5,8};

class Zoomer: public QwtPlotZoomer
{
        public:
                Zoomer(QwtPlotCanvas *canvas)
                : QwtPlotZoomer(canvas)
                {
                        setTrackerMode(AlwaysOn);
                }

                virtual QwtText trackerText(const QwtDoublePoint &pos) const
                {
                        QColor bg(Qt::white);
                        bg.setAlpha(200);

                        QVariant yValue = pos.y();
                        yValue = yValue.toInt();
                        QwtText text;
                    &nbs p;   text.setText(yValue.toString());
                        text.setBackgroundBrush( QBrush( bg ));
                        return text;
                }
};


DataPlot::DataPlot(QWidget *parent):
    QwtPlot(parent)
{
        QwtPainter::setDeviceClipping(false);

#if QT_VERSION >= 0x040000
#ifdef Q_WS_X11
    /*
        Qt::WA_PaintOnScreen is only supported for X11, but leads
        to substantial bugs with Qt 4.2.x/Windows
        */
        canvas()->setAttribute(Qt::WA_PaintOnScreen, true);
#endif
#endif
       
    // Assign a title
        setTitle("A Simple plot");

        crv.setPen(QColor(Qt::darkBlue));
        crv.setStyle(QwtPlotCurve::Lines);
        crv.setRenderHint(QwtPlotItem::RenderAntialiased);

        crv.setRawData(xval,yval,Size);
        crv.attach(this);

        // Axis
        setAxisTitle(QwtPlot::xBottom, "Time/seconds");
        setAxisScale(QwtPlot::xBottom, 1, 12);

        setAxisTitle(QwtPlot::yLeft, "Values");
        setAxisScale(QwtPlot::yLeft, 0, 15);
}


Dialog::Dialog(QWidget *parent)
        :QDialog(parent)
{
        DataPlot *plot = new DataPlot(this);
        d_zoomer = new Zoomer(plot->canvas());
        QVBoxLayout *layout = new QVBoxLayout;
        layout->addWidget(plot);
        setLayout(layout);
        resize(800,600);
}

I'm using QT-4.4 and Qwt-svn.

Where is the error?

Thanks
Giuseppe

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
qwt-interest mailing list
qwt-interest <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qwt-interest
Uwe Rathmann | 2 Jul 20:11

Re: Overloaded QwtPlotPicker::trackerText but no text near mouse pointer

On Wednesday 02 July 2008 15:51, Giuseppe Calà wrote:
>  virtual QwtText trackerText(const QwtDoublePoint &pos) const {
>       QColor bg(Qt::white);
>       bg.setAlpha(200);
>
>       QVariant yValue = pos.y();
>       yValue = yValue.toInt();
>       QwtText text;
>       text.setText(yValue.toString());
>       text.setBackgroundBrush( QBrush( bg ));
>       return text;
>   }

I checked this code in the spectrogram example with Qwt 5.1 and Qt 4.4.0 on 
Linux/X11 without any problems. 

Uwe

PS1: If you want to convert a number better use QString. 

F.e:
QString yValue;
yValue.setNum(pos.y());

PS2: If you want to convert a double to an int use qRound() or simple cast it.

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
qwt-interest mailing list
qwt-interest <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qwt-interest

Re: Overloaded QwtPlotPicker::trackerText but no text near mouse pointer

But I have to use svn version of qwt because in my main application I'm using Knut's qwt_bars_item. In previous qt4.3-qwt-svn it worked fine.

Is it possible that the error is only in the new svn code?

Thanks

2008/7/2 Uwe Rathmann <Uwe.Rathmann <at> tigertal.de>:
On Wednesday 02 July 2008 15:51, Giuseppe Calà wrote:
>  virtual QwtText trackerText(const QwtDoublePoint &pos) const {
>       QColor bg(Qt::white);
>       bg.setAlpha(200);
>
>       QVariant yValue = pos.y();
>       yValue = yValue.toInt();
>       QwtText text;
>       text.setText(yValue.toString());
>       text.setBackgroundBrush( QBrush( bg ));
>       return text;
>   }

I checked this code in the spectrogram example with Qwt 5.1 and Qt 4.4.0 on
Linux/X11 without any problems.

Uwe

PS1: If you want to convert a number better use QString.

F.e:
QString yValue;
yValue.setNum(pos.y());

PS2: If you want to convert a double to an int use qRound() or simple cast it.


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
qwt-interest mailing list
qwt-interest <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qwt-interest

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
qwt-interest mailing list
qwt-interest <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qwt-interest
Uwe Rathmann | 3 Jul 08:21

Re: Overloaded QwtPlotPicker::trackerText but no text near mouse pointer

On Wednesday 02 July 2008 22:00, Giuseppe Calà wrote:

> But I have to use svn version of qwt because in my main application I'm
> using Knut's qwt_bars_item. In previous qt4.3-qwt-svn it worked fine.
>
> Is it possible that the error is only in the new svn code?

Your code also works in the spectrogram example of qwt-svn.

Uwe

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
qwt-interest mailing list
qwt-interest <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qwt-interest

Re: Overloaded QwtPlotPicker::trackerText but no text near mouse pointer

I have re-downloaded qwt-5.2 but again it not works neither in linux nor in windows. I have attached some files to test the code alone (not in spectrogram example). Can anybody else test it?

Thanks

2008/7/3 Uwe Rathmann <Uwe.Rathmann <at> tigertal.de>:
On Wednesday 02 July 2008 22:00, Giuseppe Calà wrote:

> But I have to use svn version of qwt because in my main application I'm
> using Knut's qwt_bars_item. In previous qt4.3-qwt-svn it worked fine.
>
> Is it possible that the error is only in the new svn code?

Your code also works in the spectrogram example of qwt-svn.

Uwe

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
qwt-interest mailing list
qwt-interest <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qwt-interest

Attachment (main.cpp): text/x-c++src, 180 bytes
Attachment (trackplot.pro): application/octet-stream, 444 bytes
Attachment (dialog.h): text/x-chdr, 350 bytes
Attachment (dialog.cpp): text/x-c++src, 1715 bytes
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
qwt-interest mailing list
qwt-interest <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qwt-interest
Joey Mukherjee | 3 Jul 12:22
Favicon

Re: Overloaded QwtPlotPicker::trackerText but no text near mouse pointer

Works here on Windows with Qt 4.3 and Qwt trunk, rev. 406.

On Thu, Jul 3, 2008 at 4:13 AM, Giuseppe Calà <jiveaxe <at> gmail.com> wrote:
I have re-downloaded qwt-5.2 but again it not works neither in linux nor in windows. I have attached some files to test the code alone (not in spectrogram example). Can anybody else test it?

Thanks

2008/7/3 Uwe Rathmann <Uwe.Rathmann <at> tigertal.de>:

On Wednesday 02 July 2008 22:00, Giuseppe Calà wrote:

> But I have to use svn version of qwt because in my main application I'm
> using Knut's qwt_bars_item. In previous qt4.3-qwt-svn it worked fine.
>
> Is it possible that the error is only in the new svn code?

Your code also works in the spectrogram example of qwt-svn.

Uw


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
qwt-interest mailing list
qwt-interest <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qwt-interest
Giuseppe Calà | 3 Jul 12:30

Re: Overloaded QwtPlotPicker::trackerText but no text near mouse pointer

I'm using QT 4.4

Bye

On Thursday 03 July 2008 12:22:51 Joey Mukherjee wrote:
> Works here on Windows with Qt 4.3 and Qwt trunk, rev. 406.
>
> On Thu, Jul 3, 2008 at 4:13 AM, Giuseppe Calà <jiveaxe <at> gmail.com> wrote:
> > I have re-downloaded qwt-5.2 but again it not works neither in linux nor
> > in windows. I have attached some files to test the code alone (not in
> > spectrogram example). Can anybody else test it?
> >
> > Thanks
> >
> > 2008/7/3 Uwe Rathmann <Uwe.Rathmann <at> tigertal.de>:
> >
> > On Wednesday 02 July 2008 22:00, Giuseppe Calà wrote:
> >> > But I have to use svn version of qwt because in my main application
> >> > I'm using Knut's qwt_bars_item. In previous qt4.3-qwt-svn it worked
> >> > fine.
> >> >
> >> > Is it possible that the error is only in the new svn code?
> >>
> >> Your code also works in the spectrogram example of qwt-svn.
> >>
> >> Uw

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
qwt-interest mailing list
qwt-interest <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qwt-interest

Re: Overloaded QwtPlotPicker::trackerText but no text near mouse pointer

I have some news:
yesterday on a notebook I have installed kubuntu hardy x86, installed qt4.4 from ubuntu repositories and downloaded and installed the last svn version of qwt. I have tryed some examples from svn and they work fine. So I have compiled the code attached in my previous post and the tracker doesn't work: no coordinate near the mouse pointer.

If my code is exact well there is a compatibility issue between qwt-svn and qt4.4. Again, if somebody can confirm this will be very appreciated.

Best Regards,
Giuseppe

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
qwt-interest mailing list
qwt-interest <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qwt-interest
Matthias Reich | 1 Dec 16:26

Re: Overloaded QwtPlotPicker::trackerText but no text near mouse pointer

Hello,

how can I realize a polygon selection with more than 2 points?

Currently, when I use the default QwtPicker::PolygonSelection like 
below, I get two points. The selected signal gets emitted, when I select 
the second point.

This is all I use:
    polygonPicker = new QwtPicker(qp->canvas());
    polygonPicker->setSelectionFlags(QwtPicker::PolygonSelection | 
QwtPicker::ClickSelection);
    polygonPicker->setRubberBand(QwtPicker::PolygonRubberBand);
    polygonPicker->setRubberBandPen( QPen(white,2) );
    polygonPicker->setTrackerMode(QwtPicker::AlwaysOn);
    polygonPicker->setEnabled(false);

and later, on a button press I do
    polygonPicker->setEnabled(true);

after which I click twice in the plot, and receive an array of 2 points 
with identical coordinates in the connected SLOT.

Where do I lack something ?

Cheers,
Matthias

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Matthias Reich | 1 Dec 17:33

Re: Overloaded QwtPlotPicker::trackerText but no text near mouse pointer

Matthias Reich wrote:
> Hello,
>
> how can I realize a polygon selection with more than 2 points?
>
> Currently, when I use the default QwtPicker::PolygonSelection like 
> below, I get two points. The selected signal gets emitted, when I select 
> the second point.
>
> This is all I use:
>     polygonPicker = new QwtPicker(qp->canvas());
>     polygonPicker->setSelectionFlags(QwtPicker::PolygonSelection | 
> QwtPicker::ClickSelection);
>     polygonPicker->setRubberBand(QwtPicker::PolygonRubberBand);
>     polygonPicker->setRubberBandPen( QPen(white,2) );
>     polygonPicker->setTrackerMode(QwtPicker::AlwaysOn);
>     polygonPicker->setEnabled(false);
>
> and later, on a button press I do
>     polygonPicker->setEnabled(true);
>
> after which I click twice in the plot, and receive an array of 2 points 
> with identical coordinates in the connected SLOT.
>
> Where do I lack something ?
>   

I kind of found out by accident (and code search) that appending a point 
happens on QwtPicker::MouseSelect2 and the selection is started and 
ended (!) by QwtPicker::MouseSelect1. This is not fully intuitive, as I 
would have expected to use a different click to end the selection than I 
use for starting it.

Anyway. Using
    polygonPicker->setMousePattern(QwtEventPattern::MouseSelect1,
            Qt::RightButton );
    polygonPicker->setMousePattern(QwtEventPattern::MouseSelect2,
            Qt::LeftButton );

now lets me start the selection on a right-click, add as many points as 
i like on left clicks and ends the selection with another right click.

Sorry for bothering, but if there's a simple way to make it such that 
left clicks start and add points, and a right click ends it, please let 
me know.

Cheers,
Matthias

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Uwe Rathmann | 2 Dec 08:21

Re: Overloaded QwtPlotPicker::trackerText but no text near mouse pointer

On Monday 01 December 2008 17:33, Matthias Reich wrote:

> Sorry for bothering, but if there's a simple way to make it such that
> left clicks start and add points, and a right click ends it, please let
> me know.

The mapping from key/mouse events into Begin/Append/End commands is done 
through a state machine. You can overload QwtPlotPicker::stateMachine() and 
return your own type of state machine.

Your state machine could be derived from QwtPickerPolygonMachine. Then all you 
need to do is to return an End command for different events ( f.e. 
MouseSelect3, ... ) and to block the MouseSelect1 events for states != 0.
But of course you can also implement your own type of state machine from 
scratch.

The concept of the state machines might be a bit "overengineered" and not too 
intuitive, but once understood you can completely customize your picker 
operations.

Uwe

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

Gmane