翻譯|使用教程|編輯:鮑佳佳|2021-03-10 11:46:55.967|閱讀 569 次
概述:StocQt應(yīng)用呈現(xiàn)納斯達(dá)克100股票列表的第一個股票的走勢圖。它允許用戶從列表中選擇另一種股票,并使用從離線數(shù)據(jù)集中獲取所需數(shù)據(jù)XMLHttpRequest。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Qt quick演示-StocQt
Qt是一個跨平臺框架,通常用作圖形工具包,它不僅創(chuàng)建CLI應(yīng)用程序中非常有用。而且它也可以在三種主要的臺式機(jī)操作系統(tǒng)以及移動操作系統(tǒng)(如Symbian,Nokia Belle,Meego Harmattan,MeeGo或BB10)以及嵌入式設(shè)備,Android(Necessitas)和iOS的端口上運(yùn)行。現(xiàn)在我們?yōu)槟闾峁┝嗣赓M(fèi)的試用版。
Qt組件推薦:
NASDAQ-100的可配置庫存圖表。
StocQt應(yīng)用呈現(xiàn)納斯達(dá)克100股票列表的第一個股票的走勢圖。它允許用戶從列表中選擇另一種股票,并使用從離線數(shù)據(jù)集中獲取所需數(shù)據(jù)XMLHttpRequest。
該應(yīng)用程序使用幾種自定義類型,例如Button,CheckBox,StockChart,StockInfo,StockView等。這些類型用于以可讀形式顯示庫存數(shù)據(jù),還可以讓用戶自定義趨勢圖。例如,用戶可以選擇查看股票價格的每周,每月,每季度或半年趨勢。
該應(yīng)用程序使用ObjectModel類型來訪問它依賴的兩個可視數(shù)據(jù)模型。
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模型是一個靜態(tài)數(shù)據(jù)模型,該模型列出了NASDAQ-100股票,其中包含基本信息,例如stockId,名稱,價值,更改等。如果用戶要從列表中選擇另一只股票,則應(yīng)用程序?qū)⑹褂么藬?shù)據(jù)模型。
StockView是一個復(fù)雜的數(shù)據(jù)模型,可顯示所選股票的趨勢圖。它使用另一種自定義類型StockChart,它使用Canvas呈現(xiàn)股票價格的圖形趨勢。在應(yīng)用程序的生命周期中,大部分時間都使用此數(shù)據(jù)模型。
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() + " |" } } }
為了更好地了解應(yīng)用程序,請使用Qt Creator瀏覽其代碼。
====================================================
想要了解或購買Qt正版授權(quán)的朋友,歡迎
Qt技術(shù)交流群現(xiàn)已開通,QQ搜索群號“765444821”或者掃描下方二維碼即可加入
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自: