MainWidget::MainWidget(QString viewTitle,QWidget *parent) :
QWidget(parent)
{
this->title = viewTitle;
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
setMinimumSize(400,280);
//设置坐标
QFont titleFont;
titleFont.setFamily("微软雅黑");
titleFont.setPointSize(7);
yAxis = new QValueAxis();
yAxis->setTitleText("力矩(N.m)");
yAxis->setTitleFont(titleFont);
yAxis->setRange(-100,100);
xAxis = new QValueAxis();
xAxis->setTitleText("角度(°)");
xAxis->setTitleFont(titleFont);
xAxis->setRange(0,200);
m_chart = new QChart();
m_chart->setMargins(QMargins(0,0,0,0));
m_chart->setTitle(viewTitle);
m_chart->setTheme(QChart::ChartThemeBlueCerulean);
//m_chart->setDropShadowEnabled(true);//背景阴影
m_chart->addAxis(yAxis, Qt::AlignLeft);
m_chart->addAxis(xAxis, Qt::AlignBottom);
m_chart->layout()->setContentsMargins(0, 0, 0, 0);//设置外边界全部为0
m_chart->setMargins(QMargins(0, 0, 0, 0));//设置内边界全部为0
m_chart->setBackgroundRoundness(0); //设置背景区域无圆角
m_chartView = new ChartView(m_chart, this);
m_mainLayout = new QGridLayout;
m_mainLayout->addWidget(m_chartView, 0, 1, 3, 1);
m_mainLayout->setContentsMargins(0,0,0,0);
setLayout(m_mainLayout);
setLegendVisible(false);
//设置抽屉
initFlowPanel();
}