diff --git a/src/main.cpp b/src/main.cpp index 49a44f3..615092b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,7 @@ int main(int argc, char *argv[]) { QApplication application(argc, argv); MainWindow window; - window.show(); + window.showMaximized(); return application.exec(); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9c81350..acfce8f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -207,8 +207,6 @@ MainWindow::MainWindow(QWidget *parent) const auto metric = sheet::make_metric(category); get_label(*m_ui, category)->setText(QString("%1 (%2 mm x %3 mm)").arg(name(category), QString::number(metric.w), QString::number(metric.h))); } - - resize(1600, 800); } MainWindow::~MainWindow() { diff --git a/src/widgets/graphics-view.cpp b/src/widgets/graphics-view.cpp index f559ac7..ccafee1 100644 --- a/src/widgets/graphics-view.cpp +++ b/src/widgets/graphics-view.cpp @@ -2,13 +2,21 @@ GraphicsView::GraphicsView(QWidget *parent) : QGraphicsView(parent) { + setViewportUpdateMode(QGraphicsView::ViewportUpdateMode::MinimalViewportUpdate); } -void GraphicsView::showEvent(QShowEvent *) { - //setViewport(new QGLWidget(QGLFormat(QGL::SingleBuffer))); //moved to showEvent because of strange random artefacts - setViewportUpdateMode(QGraphicsView::ViewportUpdateMode::MinimalViewportUpdate); - centerOn(0.0, 0.0); +void GraphicsView::resizeEvent(QResizeEvent *event) { + center(); + QGraphicsView::resizeEvent(event); } -void GraphicsView::wheelEvent(QWheelEvent *) { +void GraphicsView::showEvent(QShowEvent *event) { + center(); + QGraphicsView::showEvent(event); +} + +void GraphicsView::wheelEvent(QWheelEvent *) {} //eat event + +void GraphicsView::center() { + centerOn(0.0, 0.0); } diff --git a/src/widgets/graphics-view.h b/src/widgets/graphics-view.h index 8852184..c91f2dd 100644 --- a/src/widgets/graphics-view.h +++ b/src/widgets/graphics-view.h @@ -7,6 +7,10 @@ class GraphicsView : public QGraphicsView { GraphicsView(QWidget *parent = nullptr); protected: + void resizeEvent(QResizeEvent *) final; void showEvent(QShowEvent *) final; void wheelEvent(QWheelEvent *) final; + +private: + void center(); };