plot: Convert PlotView to derive from QAbstractScrollArea

This commit is contained in:
Mike Walters
2016-03-02 23:36:25 +00:00
parent fc019afb32
commit d5ebd4f2cf
4 changed files with 5 additions and 10 deletions

View File

@@ -26,17 +26,13 @@
MainWindow::MainWindow()
{
setWindowTitle(tr("inspectrum"));
scrollArea.viewport()->installEventFilter(this);
dock = new SpectrogramControls(tr("Controls"), this);
dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
addDockWidget(Qt::LeftDockWidgetArea, dock);
plots = new PlotView();
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(plots);
scrollArea.setLayout(layout);
setCentralWidget(&scrollArea);
setCentralWidget(plots);
}
void MainWindow::openFile(QString fileName)

View File

@@ -36,7 +36,6 @@ public slots:
void openFile(QString fileName);
private:
QScrollArea scrollArea;
SpectrogramControls *dock;
PlotView *plots;
};

View File

@@ -33,7 +33,7 @@
PlotView::PlotView()
{
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
}
void PlotView::refreshSources()
@@ -117,7 +117,7 @@ void PlotView::paintEvent(QPaintEvent *event)
if (lastSample - firstSample <= 0) return;
QRect rect = QRect(0, 0, width(), height());
QPainter painter(this);
QPainter painter(viewport());
painter.fillRect(rect, Qt::black);

View File

@@ -19,12 +19,12 @@
#pragma once
#include <QDockWidget>
#include <QAbstractScrollArea>
#include <QPaintEvent>
#include "inputsource.h"
#include "plot.h"
class PlotView : public QDockWidget
class PlotView : public QAbstractScrollArea
{
Q_OBJECT