Results 1 to 2 of 2

Thread: QGraphicsView and QwtPlot

  1. #1
    Join Date
    Nov 2009
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Arrow QGraphicsView and QwtPlot

    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:

    Qt Code:
    1. class MyZoomer: public QwtPlotZoomer
    2. {
    3. public:
    4. MyZoomer(QwtPlotCanvas *canvas):
    5. QwtPlotZoomer(canvas)
    6. {
    7. setTrackerMode(AlwaysOn);
    8. }
    9.  
    10. virtual QwtText trackerText(const QwtDoublePoint &pos) const
    11. {
    12. QColor bg(Qt::white);
    13. bg.setAlpha(200);
    14.  
    15. QwtText text = QwtPlotZoomer::trackerText(pos);
    16. text.setBackgroundBrush( QBrush( bg ));
    17. return text;
    18. }
    19. };
    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:

    Qt Code:
    1. 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.

  2. #2
    Join Date
    Nov 2009
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsView and QwtPlot

    In short, the problem is: zooming doesn't work when placing QwtPlot object in QGraphicsScene and drawing it on QGraphicsView.

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.