update highline setting

This commit is contained in:
2025-09-01 10:02:14 +08:00
parent 6ede3eff92
commit 0203540b55
5 changed files with 48 additions and 15 deletions

Binary file not shown.

View File

@@ -99,10 +99,10 @@ void HighlightDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt
if (isHighlighted) {
// 设置高亮背景
painter->fillRect(opt.rect, QColor(255, 192, 203)); // 浅黄色背景
// 设置加粗字体
QFont boldFont = opt.font;
boldFont.setBold(true);
painter->setFont(boldFont);
//QFont boldFont = opt.font;// 设置加粗字体
//boldFont.setBold(true);
//painter->setFont(boldFont);
// 绘制文本
painter->setPen(opt.palette.color(QPalette::Text));

View File

@@ -239,10 +239,17 @@ void QBigOrderViewer::onBigOrderAdded(const BigOrderInfo &order)
m_model->insertRow(row);
setRowData(row, newOrder);
// 为订单生成唯一标识
QString orderId = QString("%1_%2_%3")
.arg(order.code)
.arg(QString::number(order.price, 'f', 2))
.arg(QDateTime::currentMSecsSinceEpoch());
// 设置高亮标记
for (int col = 0; col < m_model->columnCount(); ++col) {
QModelIndex index = m_model->index(row, col);
m_model->setData(index, true, IsHighlightedRole);
m_model->setData(index, orderId, Qt::UserRole + 102); // 存储唯一标识
}
// 通知视图更新
@@ -251,16 +258,32 @@ void QBigOrderViewer::onBigOrderAdded(const BigOrderInfo &order)
emit m_model->dataChanged(topLeft, bottomRight);
// 2秒后取消高亮
QTimer::singleShot(2000, this, [this, row]() {
for (int col = 0; col < m_model->columnCount(); ++col) {
QModelIndex index = m_model->index(row, col);
QTimer::singleShot(2000, this, [this, orderId]() {
for (int row = 0; row < m_model->rowCount(); ++row) {
QModelIndex index = m_model->index(row, 0);
m_model->setData(index, false, IsHighlightedRole);
QString currentOrderId = index.data(Qt::UserRole + 102).toString();
if (currentOrderId == orderId) {
for (int col = 0; col < m_model->columnCount(); ++col) {
QModelIndex cellIndex = m_model->index(row, col);
m_model->setData(cellIndex, false, IsHighlightedRole);
}
// 通知视图更新
QModelIndex topLeft = m_model->index(row, 0);
QModelIndex bottomRight = m_model->index(row, m_model->columnCount() - 1);
emit m_model->dataChanged(topLeft, bottomRight);
break; // 找到后退出循环
}
}
//// 通知视图更新
//QModelIndex topLeft = m_model->index(row, 0);
//QModelIndex bottomRight = m_model->index(row, m_model->columnCount() - 1);
//emit m_model->dataChanged(topLeft, bottomRight);
});
// 确保代理模型按时间降序排序,新数据在顶部

View File

@@ -90,6 +90,11 @@ QVector<BigOrderInfo> QOrderProcessor::findMaxVolumeItem(const OrderBookData & d
const OrderBookEntry* maxItem;
QVector<OrderBookEntry> items = data.asks;
for (int i = 0; i < items.size(); i++) {
// 不处理刚打开程序时,推送过来的摆盘数据
if (data.askTime == NULL)
continue;
// 同一个价格挡位的订单中股票数量大于,阈值才有可能是大单
if (volume < items[i].volume) {
for (int j = 0; j< items[i].details.size(); j++) // 超过list的最大数量就不会返回数据了
@@ -121,6 +126,11 @@ QVector<BigOrderInfo> QOrderProcessor::findMaxVolumeItem(const OrderBookData & d
items = data.bids;
for (int i = 0; i < items.size(); i++) {
// 不处理刚打开程序时,推送过来的摆盘数据
if (data.bidTime == NULL)
continue;
// 同一个价格挡位的订单中股票数量大于,阈值才有可能是大单
if (volume < items[i].volume) {
for (int j = 0; j< items[i].details.size(); j++)

View File

@@ -1,9 +1,9 @@
<EFBFBD><EFBFBD>Ʊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
09885,200000
00581,30000
00581,1.02e+06
03383,800000
02666,500000
00839,500000
06098,600000
06865,10000
00700,1000
06865,50000
00700,8000
1 股票代码 检测阈值
2 09885 200000
3 00581 30000 1.02e+06
4 03383 800000
5 02666 500000
6 00839 500000
7 06098 600000
8 06865 10000 50000
9 00700 1000 8000