From d5ebd4f2cf9ba81ea358507523bc3aefbde9cfe0 Mon Sep 17 00:00:00 2001 From: Mike Walters Date: Wed, 2 Mar 2016 23:36:25 +0000 Subject: [PATCH] plot: Convert PlotView to derive from QAbstractScrollArea --- mainwindow.cpp | 6 +----- mainwindow.h | 1 - plotview.cpp | 4 ++-- plotview.h | 4 ++-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index b284629..737f8e9 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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) diff --git a/mainwindow.h b/mainwindow.h index b5510c2..5601386 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -36,7 +36,6 @@ public slots: void openFile(QString fileName); private: - QScrollArea scrollArea; SpectrogramControls *dock; PlotView *plots; }; diff --git a/plotview.cpp b/plotview.cpp index b01e2dd..7f8fca4 100644 --- a/plotview.cpp +++ b/plotview.cpp @@ -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); diff --git a/plotview.h b/plotview.h index 9a9d3be..2600ade 100644 --- a/plotview.h +++ b/plotview.h @@ -19,12 +19,12 @@ #pragma once -#include +#include #include #include "inputsource.h" #include "plot.h" -class PlotView : public QDockWidget +class PlotView : public QAbstractScrollArea { Q_OBJECT