mirror of
https://github.com/miek/inspectrum.git
synced 2026-03-15 04:37:08 +01:00
plot: Convert PlotView to derive from QAbstractScrollArea
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -36,7 +36,6 @@ public slots:
|
||||
void openFile(QString fileName);
|
||||
|
||||
private:
|
||||
QScrollArea scrollArea;
|
||||
SpectrogramControls *dock;
|
||||
PlotView *plots;
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user