mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-04-01 02:42:39 +08:00
35 lines
1.3 KiB
C++
35 lines
1.3 KiB
C++
#include "MainWindow.h"
|
|
|
|
#include <QChart>
|
|
#include <QChartView>
|
|
#include <QLabel>
|
|
#include <QLineSeries>
|
|
#include <QTimer>
|
|
|
|
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
|
|
{
|
|
setFixedSize(900, 600);
|
|
// Create the dock manager. Because the parent parameter is a QMainWindow
|
|
// the dock manager registers itself as the central widget.
|
|
m_DockManager = new ads::CDockManager(this);
|
|
|
|
// Create example chart using OpenGL
|
|
QChartView* chart_view = new QChartView(this);
|
|
QList<QPointF> points = {{0, 0}, {2, 0}, {2, 5}, {4, 5}, {4, -2}, {6, -2}};
|
|
QLineSeries* series = new QLineSeries(this);
|
|
series->setUseOpenGL(true);
|
|
series->replace(points);
|
|
chart_view->chart()->addSeries(series);
|
|
chart_view->chart()->createDefaultAxes();
|
|
chart_view->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
// Create a dock widget with the title "Chart with OpenGL" and set the created
|
|
// chart as the dock widget content
|
|
ads::CDockWidget* DockWidget = new ads::CDockWidget("Chart with OpenGL");
|
|
DockWidget->setWidget(chart_view);
|
|
DockWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
// Add the dock widget to the top dock widget area
|
|
m_DockManager->addDockWidget(ads::CenterDockWidgetArea, DockWidget);
|
|
}
|