Hello!
I'm trying to place a QwtPlot with QwtPlotSpectrogram on the QGraphicsView.
I took the standard example "spectrogram", adapted it for my needs. And my spectrogram successfully draws on QGraphicsView with QGraphicsScene, but one thing doesn't work well.
There is class MyZoomer in the example:
{
public:
{
setTrackerMode(AlwaysOn);
}
virtual QwtText trackerText
(const QwtDoublePoint
&pos
) const {
bg.setAlpha(200);
text.
setBackgroundBrush( QBrush( bg
));
return text;
}
};
class MyZoomer: public QwtPlotZoomer
{
public:
MyZoomer(QwtPlotCanvas *canvas):
QwtPlotZoomer(canvas)
{
setTrackerMode(AlwaysOn);
}
virtual QwtText trackerText(const QwtDoublePoint &pos) const
{
QColor bg(Qt::white);
bg.setAlpha(200);
QwtText text = QwtPlotZoomer::trackerText(pos);
text.setBackgroundBrush( QBrush( bg ));
return text;
}
};
To copy to clipboard, switch view to plain text mode
I made no changes in it, but it doesn't work when I place QwtPlot on the QGraphicsView.
I create Plot in the following way:
Plot
* plot
= new Plot
(NULL, data,
QCoreApplication::translate("QFrame",
"Grid plot"));
Plot* plot = new Plot(NULL, data, QCoreApplication::translate("QFrame", "Grid plot"));
To copy to clipboard, switch view to plain text mode
And first parameter is the parent. It's null because:
1. If I pass my QGraphicsView* view I will get error (cannot convert from QGraphicsView to QWidget).
2. If I pass the main window pointer QwtPlot won't be showed at all.
I suppose this is the reason why zooming doesn't work.
What should I do?
Thanks a lot.
Bookmarks