From 637610bcf851d70657c2dcf251d6daed2429a9a5 Mon Sep 17 00:00:00 2001 From: wumu <mayi@mayi.com> Date: 星期三, 26 二月 2025 22:59:54 +0800 Subject: [PATCH] 0226 --- regularinvestment.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 51 insertions(+), 3 deletions(-) diff --git a/regularinvestment.cpp b/regularinvestment.cpp index dc02488..75aa3f0 100644 --- a/regularinvestment.cpp +++ b/regularinvestment.cpp @@ -9,6 +9,9 @@ #include <qnetworkreply.h> #include <QDebug> + +#pragma execution_character_set("utf-8") + RegularInvestment::RegularInvestment(QWidget *parent) : QMainWindow(parent), ui(new Ui::RegularInvestment) @@ -21,6 +24,7 @@ m_nameCodes["涓浗绁炲崕"]= "SH601088"; m_nameCodes["涓浗鐢典俊"]= "SH601728"; m_nameCodes["涓浗绉诲姩"]= "SH600941"; + m_nameCodes["宸ュ晢閾惰"]= "SH601398"; // 澶勭悊鏁版嵁鐖彇鐨勬搷浣� @@ -48,12 +52,19 @@ // 鍘昏姹傞椤� m_manager.get(m_request); - // 澶勭悊妯″瀷 + // 澶勭悊妯″瀷 鍥炴祴 m_model = new QStandardItemModel(0,7,this); ui->tableView->setModel(m_model); QStringList labels; labels<<"鏃堕棿"<<"涔板叆浠锋牸"<<"鏁伴噺(鎵�)"<<"鎵�闇�閲戦(鍏�)"<<"鏈�鏂颁环鏍�"<<"鐩堜簭姣�"<<"鐩堜簭閲戦"; m_model->setHorizontalHeaderLabels(labels); + + // 瀹氭姇涔板叆 + m_modelBuy = new QStandardItemModel(0,9,this); + ui->tableView_buyRecord->setModel(m_modelBuy); + QStringList buyLabels; + buyLabels<<"鐢宠鏃堕棿"<<"鐢宠浠锋牸(鍏�)"<<"鎴愪氦鏃堕棿"<<"鎴愪氦浠锋牸(鍏�)"<<"璐拱鏁伴噺(鎵�)"<<"鎵�闇�閲戦(鍏�)"<<"鏈�鏂颁环鏍�(鍏�)"<<"鐩堜簭姣�"<<"鐩堜簭閲戦(鍏�)"; + m_modelBuy->setHorizontalHeaderLabels(buyLabels); } @@ -66,9 +77,14 @@ void RegularInvestment::showClosePrice(QString name, QString closePrice) { qDebug()<<name<<closePrice; - ui->label_closePrice->setText(closePrice); + if(ui->comboBox->currentText() == name){ + ui->label_closePrice->setText(closePrice); + on_lineEdit_2_returnPressed(); // 鍒锋柊鎬讳环 + }else if(ui->comboBox_3->currentText() == name){ + ui->label_closePrice_2->setText(closePrice); + on_lineEdit_buyNum_returnPressed(); // 鍒锋柊鎬讳环 + } - on_lineEdit_2_returnPressed(); // 鍒锋柊鎬讳环 } void RegularInvestment::on_comboBox_currentIndexChanged(const QString &arg1) @@ -203,3 +219,35 @@ ui->label_winAll->setText(QString::number(allWin)); ui->label_allRate->setText(QString::number((allWin/allBuy)*100)); } + +void RegularInvestment::on_comboBox_3_currentIndexChanged(const QString &arg1) +{ + qDebug()<<"寮�濮嬪畾鎶曞綋鍓嶈偂绁ㄤ负:"<<arg1; + emit getClosePriceSignal(arg1); +} + +void RegularInvestment::on_lineEdit_buyNum_returnPressed() +{ + qDebug()<<ui->lineEdit_buyNum->text(); + double price = ui->lineEdit_buyNum->text().toInt()* 100 * ui->label_closePrice_2->text().toDouble(); + ui->lineEdit_money->setText(QString::number(price)); +} + +void RegularInvestment::on_pushButton_buy_clicked() +{ + QString applyTime = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"); + QString name = ui->comboBox_3->currentText(); + QString code = m_nameCodes[name]; + QString numStr = ui->lineEdit_buyNum->text(); + QString applyPrice = ui->label_closePrice_2->text(); + double needMoney = numStr.toInt() * applyPrice.toDouble()*100; + + int rowCnt = m_modelBuy->rowCount(); + m_modelBuy->setRowCount(rowCnt+1); + + m_modelBuy->setItem(rowCnt,0,new QStandardItem(applyTime)); + m_modelBuy->setItem(rowCnt,1,new QStandardItem(applyPrice)); + m_modelBuy->setItem(rowCnt,4,new QStandardItem(numStr)); + m_modelBuy->setItem(rowCnt,5,new QStandardItem(QString::number(needMoney))); + +} -- Gitblit v1.8.0