update QBigOrderViewer.cpp 解决页面刷新时,时间列显示重叠问题
This commit is contained in:
@@ -381,7 +381,7 @@ QString QMainwindow::toFixedDigitNumber(const QString& input) {
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>ȫΪ0-9<><39><EFBFBD><EFBFBD>
|
||||
QRegularExpression re("^\\d+$");
|
||||
if (!re.match(input).hasMatch()) {
|
||||
return QString(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>code <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><>ʱ<EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD> <20><EFBFBD>
|
||||
return QString(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>code <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><>ʱ<EFBFBD>ȷ<EFBFBD><C8B7>ؿ<EFBFBD>
|
||||
}
|
||||
|
||||
// <20><><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>
|
||||
|
||||
Binary file not shown.
@@ -19,7 +19,7 @@
|
||||
// ==================== QBigOrderViewer ====================
|
||||
QBigOrderViewer::QBigOrderViewer(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
m_model(new QStandardItemModel(0, 7, this)),
|
||||
m_model(new QStandardItemModel(0, 8, this)),
|
||||
m_proxyModel(new QSortFilterProxyModel(this)),
|
||||
m_typeDelegate(new OrderTypeDelegate(this)),
|
||||
m_lastOrderDelegate(new HighlightDelegate(this))
|
||||
@@ -82,18 +82,15 @@ void QBigOrderViewer::initUI()
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
m_tableView->setModel(m_proxyModel);
|
||||
m_tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
|
||||
// 设置表头(股票代码、名称、类型、数量、价格、订单数、时间、时间戳)
|
||||
QStringList headers;
|
||||
headers << "股票代码" << "股票名称" << "订单类型"
|
||||
<< "股票数量" << "股票价格" << "订单档位"
|
||||
<< "时间"<< "Timestamp";
|
||||
m_model->setHorizontalHeaderLabels(headers);
|
||||
m_tableView->setColumnHidden(7, true);
|
||||
|
||||
// 设置表头(股票代码、名称、类型、数量、价格、订单数、时间)
|
||||
m_model->setHorizontalHeaderLabels(
|
||||
QStringList()
|
||||
<< "股票代码"
|
||||
<< "股票名称"
|
||||
<< "订单类型"
|
||||
<< "股票数量"
|
||||
<< "股票价格"
|
||||
<< "订单档位"
|
||||
<< "时间"
|
||||
);
|
||||
|
||||
// 设置表头文字居中
|
||||
for (int col = 0; col < m_model->columnCount(); ++col) {
|
||||
@@ -110,7 +107,7 @@ void QBigOrderViewer::initUI()
|
||||
// 设置高亮委托到所有列
|
||||
m_tableView->setItemDelegate(m_lastOrderDelegate);
|
||||
|
||||
// 默认按时间列(第6列,索引5)升序排序 -> 新插入的行放在最顶上,故修改为降序排序 @2025.08.30 stone
|
||||
// 默认按时间列(第7列,索引6)升序排序 -> 新插入的行放在最顶上,故修改为降序排序 @2025.08.30 stone
|
||||
const int timeColumnIndex = 6;
|
||||
m_proxyModel->sort(timeColumnIndex, Qt::DescendingOrder);
|
||||
|
||||
@@ -214,6 +211,11 @@ void QBigOrderViewer::updateView()
|
||||
timeItem->setTextAlignment(Qt::AlignCenter);
|
||||
rowItems << timeItem;
|
||||
|
||||
// 添加时间戳列
|
||||
QStandardItem* timestampItem = new QStandardItem(order->svrRecvTime);
|
||||
timestampItem->setTextAlignment(Qt::AlignCenter);
|
||||
rowItems << timestampItem;
|
||||
|
||||
m_model->appendRow(rowItems);
|
||||
}
|
||||
}
|
||||
@@ -335,6 +337,9 @@ void QBigOrderViewer::setRowData(int row, QSharedPointer<BigOrderInfo> order)
|
||||
}
|
||||
m_model->setData(m_model->index(row, 6), timeStr);
|
||||
|
||||
// 添加时间戳列(第7列)
|
||||
m_model->setData(m_model->index(row, 7), order->svrRecvTime);
|
||||
|
||||
// 添加一个隐藏的时间戳列用于精确排序
|
||||
QDateTime fullDateTime;
|
||||
if (order->svrRecvTime.length() >= 19) {
|
||||
|
||||
Reference in New Issue
Block a user