翻譯|使用教程|編輯:鮑佳佳|2021-03-10 11:46:55.967|閱讀 569 次
概述:StocQt應用呈現納斯達克100股票列表的第一個股票的走勢圖。它允許用戶從列表中選擇另一種股票,并使用從離線數據集中獲取所需數據XMLHttpRequest。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Qt quick演示-StocQt
Qt是一個跨平臺框架,通常用作圖形工具包,它不僅創建CLI應用程序中非常有用。而且它也可以在三種主要的臺式機操作系統以及移動操作系統(如Symbian,Nokia Belle,Meego Harmattan,MeeGo或BB10)以及嵌入式設備,Android(Necessitas)和iOS的端口上運行。現在我們為你提供了免費的試用版。
Qt組件推薦:
NASDAQ-100的可配置庫存圖表。
StocQt應用呈現納斯達克100股票列表的第一個股票的走勢圖。它允許用戶從列表中選擇另一種股票,并使用從離線數據集中獲取所需數據XMLHttpRequest。
該應用程序使用幾種自定義類型,例如Button,CheckBox,StockChart,StockInfo,StockView等。這些類型用于以可讀形式顯示庫存數據,還可以讓用戶自定義趨勢圖。例如,用戶可以選擇查看股票價格的每周,每月,每季度或半年趨勢。
該應用程序使用ObjectModel類型來訪問它依賴的兩個可視數據模型。
ListView { id: root ... model: ObjectModel { StockListView { id: listView width: root.width height: root.height } StockView { id: stockView width: root.width height: root.height stocklist: listView stock: stock } } }
StockListView模型是一個靜態數據模型,該模型列出了NASDAQ-100股票,其中包含基本信息,例如stockId,名稱,價值,更改等。如果用戶要從列表中選擇另一只股票,則應用程序將使用此數據模型。
StockView是一個復雜的數據模型,可顯示所選股票的趨勢圖。它使用另一種自定義類型StockChart,它使用Canvas呈現股票價格的圖形趨勢。在應用程序的生命周期中,大部分時間都使用此數據模型。
Rectangle { id: chart ... Canvas { id: canvas ... onPaint: { numPoints = stockModel.indexOf(chart.startDate); if (chart.gridSize == 0) chart.gridSize = numPoints var ctx = canvas.getContext("2d"); ctx.globalCompositeOperation = "source-over"; ctx.lineWidth = 1; drawBackground(ctx); if (!stockModel.ready) { drawError(ctx, "No data available."); return; } var highestPrice = 0; var highestVolume = 0; var lowestPrice = -1; var points = []; for (var i = numPoints, j = 0; i >= 0 ; i -= pixelSkip, j += pixelSkip) { var price = stockModel.get(i); if (parseFloat(highestPrice) < parseFloat(price.high)) highestPrice = price.high; if (parseInt(highestVolume, 10) < parseInt(price.volume, 10)) highestVolume = price.volume; if (lowestPrice < 0 || parseFloat(lowestPrice) > parseFloat(price.low)) lowestPrice = price.low; points.push({ x: j * xGridStep, open: price.open, close: price.close, high: price.high, low: price.low, volume: price.volume }); } if (settings.drawHighPrice) drawPrice(ctx, 0, numPoints, settings.highColor, "high", points, highestPrice, lowestPrice); if (settings.drawLowPrice) drawPrice(ctx, 0, numPoints, settings.lowColor, "low", points, highestPrice, lowestPrice); if (settings.drawOpenPrice) drawPrice(ctx, 0, numPoints,settings.openColor, "open", points, highestPrice, lowestPrice); if (settings.drawClosePrice) drawPrice(ctx, 0, numPoints, settings.closeColor, "close", points, highestPrice, lowestPrice); drawVolume(ctx, 0, numPoints, settings.volumeColor, "volume", points, highestVolume); drawScales(ctx, highestPrice, lowestPrice, highestVolume); } } Text { id: fromDate color: "#000000" font.family: Settings.fontFamily font.pointSize: 8 Layout.alignment: Qt.AlignLeft text: "| " + startDate.toDateString() } Text { id: toDate color: "#000000" font.family: Settings.fontFamily font.pointSize: 8 Layout.alignment: Qt.AlignRight Layout.rightMargin: canvas.tickMargin Layout.columnSpan: 5 text: endDate.toDateString() + " |" } } }
為了更好地了解應用程序,請使用Qt Creator瀏覽其代碼。
====================================================
想要了解或購買Qt正版授權的朋友,歡迎
Qt技術交流群現已開通,QQ搜索群號“765444821”或者掃描下方二維碼即可加入
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自: