• 大小: 272KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-12
  • 语言: 其他
  • 标签: QCustomPlot  

资源简介

QCustomPlot开发示例,跟股票相关,一个展示的曲线图,别人存下来,以备需要。。。。

资源截图

代码片段和文件信息

#include “candlesticksview.h“
#include “stock.h“


CandlesticksView::CandlesticksView(QWidget *parent)
    : QCustomPlot(parent)
{
    qDebug()<<“CandlesticksView:“<
    m_dataManager = 0;
    m_curStock = 0;
    m_stockCode = ““;
    m_stockName = ““;
    m_stockCodeExpected = ““;

    m_ohlcDataMap = 0;
    m_tradeExtraDataMap = 0;

    m_plottitle = 0;
    m_candlesticks = 0;
    m_yAxis = 0;
    m_horizontalLine = 0;
    m_verticalLine = 0;

    volumeAxisRect = 0;
    m_volumePos = 0;
    m_volumeNeg = 0;
    m_volumeLeftAxis = 0;

    m_infoView = 0;
    m_leftKey = 0;
    m_focusedKey = 0;
    m_rightKey = 0;


    setInteractions(/*QCP::iRangeDrag | QCP::iRangeZoom |*/ QCP::iSelectAxes |
                    QCP::iSelectLegend | QCP::iSelectPlottables);


    //鼠标事件
    //connect(this SIGNAL(mouseDoubleClick(QMouseEvent*)) this SLOT(slotMouseDoubleClick(QMouseEvent*)));
    //connect(this SIGNAL(mousePress(QMouseEvent*)) this SLOT(slotMousePress(QMouseEvent*)));
    //connect(this SIGNAL(mouseMove(QMouseEvent*)) this SLOT(slotMouseMove(QMouseEvent*)));
    //connect(this SIGNAL(mouseRelease(QMouseEvent*)) this SLOT(slotMouseRelease(QMouseEvent*)));
    //connect(this SIGNAL(mouseWheel(QWheelEvent*)) this SLOT(slotMouseWheel(QWheelEvent*)));


    //坐标轴
    connect(xAxis SIGNAL(rangeChanged(QCPRange)) xAxis2 SLOT(setRange(QCPRange)));
    connect(yAxis SIGNAL(rangeChanged(QCPRange)) yAxis2 SLOT(setRange(QCPRange)));
    //connect(yAxis2 SIGNAL(rangeChanged(QCPRange)) yAxis SLOT(setRange(QCPRange)));
    connect(xAxis SIGNAL(rangeChanged(const QCPRange & const QCPRange &)) this SLOT(setAxisRange()));
    //connect(xAxis SIGNAL(rangeChanged(const QCPRange & const QCPRange &)) this SLOT(setAxisRange2(const QCPRange & const QCPRange &)));


    //右键
    setContextMenuPolicy(Qt::CustomContextMenu);
    connect(this SIGNAL(customContextMenuRequested(QPoint)) this SLOT(contextMenuRequest(QPoint)));

    drawCandlesticks();

}

CandlesticksView::~CandlesticksView(){
    delete m_infoView;
}

void CandlesticksView::setDataManager(DataManager *manager){
    //if(!manager){return;}
    m_dataManager = manager;
    //m_stockCode = m_allStocks.first();
    //connect(m_dataManager SIGNAL(historicalDataRead(QString)) this SLOT(historicalDataRead(QString)) Qt::QueuedConnection);
    //connect(this SIGNAL(historicalDataRequested(QString * int)) m_dataManager SLOT(readHistoricalData(QString * int)) Qt::QueuedConnection);
}

Stock * CandlesticksView::currentStock(){
    return m_curStock;
}

void CandlesticksView::mouseDoubleClickEvent(QMouseEvent *event){
    if(!m_curStock){return;}
    if(m_ohlcDataMap->isEmpty()){return;}

    if(!m_infoView){
        setInfoViewVisible(true);
        //QPoint bottomLeft = frameGeometry().bottomLeft();
        //m_infoView->move(QPoint(bottomLeft.x() bottomLeft.y

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-05-30 01:14  StocksInfo-master\
     文件         422  2016-05-30 01:14  StocksInfo-master\.gitignore
     文件        1869  2016-05-30 01:14  StocksInfo-master\API.txt
     文件       35141  2016-05-30 01:14  StocksInfo-master\LICENSE
     文件         100  2016-05-30 01:14  StocksInfo-master\README.md
     文件       21410  2016-05-30 01:14  StocksInfo-master\candlesticksview.cpp
     文件        2730  2016-05-30 01:14  StocksInfo-master\candlesticksview.h
     文件         165  2016-05-30 01:14  StocksInfo-master\common.cpp
     文件         881  2016-05-30 01:14  StocksInfo-master\common.h
     目录           0  2016-05-30 01:14  StocksInfo-master\database\
     文件       11611  2016-05-30 01:14  StocksInfo-master\database\databaseconnecter.cpp
     文件        2833  2016-05-30 01:14  StocksInfo-master\database\databaseconnecter.h
     文件       18740  2016-05-30 01:14  StocksInfo-master\database\databaseconnecterdialog.cpp
     文件        2907  2016-05-30 01:14  StocksInfo-master\database\databaseconnecterdialog.h
     文件       15175  2016-05-30 01:14  StocksInfo-master\database\databaseconnecterdialog.ui
     文件       13741  2016-05-30 01:14  StocksInfo-master\database\databaseutility.cpp
     文件        2644  2016-05-30 01:14  StocksInfo-master\database\databaseutility.h
     文件       14249  2016-05-30 01:14  StocksInfo-master\database\dataoutputdialog.cpp
     文件        1943  2016-05-30 01:14  StocksInfo-master\database\dataoutputdialog.h
     文件       10606  2016-05-30 01:14  StocksInfo-master\database\dataoutputdialog.ui
     文件        3836  2016-05-30 01:14  StocksInfo-master\database\dataprint.cpp
     文件        1496  2016-05-30 01:14  StocksInfo-master\database\dataprint.h
     文件       31294  2016-05-30 01:14  StocksInfo-master\datamanager.cpp
     文件        3366  2016-05-30 01:14  StocksInfo-master\datamanager.h
     文件        7120  2016-05-30 01:14  StocksInfo-master\downloadmanager.cpp
     文件        1520  2016-05-30 01:14  StocksInfo-master\downloadmanager.h
     文件         331  2016-05-30 01:14  StocksInfo-master\main.cpp
     文件        8273  2016-05-30 01:14  StocksInfo-master\mainwindow.cpp
     文件        1039  2016-05-30 01:14  StocksInfo-master\mainwindow.h
     文件       29568  2016-05-30 01:14  StocksInfo-master\mainwindow.ui
     文件      864647  2016-05-30 01:14  StocksInfo-master\qcustomplot.cpp
............此处省略14个文件信息

评论

共有 条评论