In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you the "sample analysis of Qt database and Chart historical data display in CAccord Craft +", which is easy to understand and well-organized. I hope it can help you solve your doubts. Here, let the editor lead you to study and study the "sample analysis of Qt database and Chart historical data display in CAccord +".
In the previous blog article specifically introduced how the QChart component draws a variety of general two-dimensional graphics, this chapter will continue to extend a new knowledge point, through the database to store the trend of node data for a certain period of time, when users submit query records through the edit box, the program automatically filters out all the data under the time node, and dynamically draws the data into the graphics component to achieve the function of dynamic query graphics.
First, create a Times table with the following code, which records the values under a certain time node of a host:
# include # include / / initialize the database / / https://www.cnblogs.com/lysharkvoid InitSql () {QSqlDatabase db = QSqlDatabase::addDatabase ("QSQLITE"); db.setDatabaseName ("lyshark.db"); if (! db.open ()) {std::cout setMinorTickCount (5); / / set the X axis scale QValueAxis * axisY = new QValueAxis / / Y axis axisY- > setRange (0100); / / Y axis range axisY- > setMinorTickCount (4); / / s set Y axis scale / / set X to Y axis data set chart- > setAxisX (axisX, series0); / / set axis chart- > setAxisY (axisY, series0) for sequence } / / generate data for sequence void MainWindow::SetData () {/ / get pointer QLineSeries * series0= (QLineSeries *) ui- > graphicsView- > chart ()-> series () .at (0); / / clear legend series0- > clear (); / / Link database QSqlDatabase db = QSqlDatabase::addDatabase ("QSQLITE"); db.setDatabaseName ("lyshark.db"); if (! db.open ()) {return } / / query the data QSqlQuery query ("SELECT * FROM Times;", db); QSqlRecord rec = query.record (); / / assign the data qreal tweets / / cycle through all records while (query.next ()) {/ / determine whether the current record is valid / / https://www.cnblogs.com/lyshark if (query.isValid ()) {QString address_value = query.value (rec.indexOf ("address"). ToString (); QString date_time = query.value (rec.indexOf ("datetime")). ToString () Int this_value = query.value (rec.indexOf ("value")) .toInt (); / / get the component string QString start_user_time = ui- > dateTimeEdit_Start- > text (); QString end_user_time = ui- > dateTimeEdit_End- > text () / / convert the time string to seconds and calculate the difference (in seconds) QDateTime start_timet = QDateTime::fromString (start_user_time, "yyyy-MM-dd hh:mm:ss"); QDateTime end_timet = QDateTime::fromString (end_user_time, "yyyy-MM-dd hh:mm:ss"); uint stime = start_timet.toTime_t () Uint etime = end_timet.toTime_t (); / / only records less than 180 seconds can be queried uint sub_time = etime-stime; if (sub_time = start_user_time.toStdString () & & date_time.toStdString () setDateTime (curDateTime); / / set time format ui- > dateTimeEdit_Start- > setDisplayFormat ("yyyy-MM-dd hh:mm:ss") Ui- > dateTimeEdit_End- > setDisplayFormat ("yyyy-MM-dd hh:mm:ss");} MainWindow::~MainWindow () {delete ui;} void MainWindow::on_pushButton_clicked () {SetData ();}
The query results are as follows:
The above is all the contents of the article "sample Analysis of Qt Database and Chart Historical data display in Cmax Candle +". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.