2026-01-22 12:57:54 +08:00
|
|
|
|
#include "resultitem.h"
|
|
|
|
|
|
#include "ui_resultitem.h"
|
|
|
|
|
|
|
|
|
|
|
|
ResultItem::ResultItem(QWidget *parent)
|
|
|
|
|
|
: QWidget(parent)
|
|
|
|
|
|
, ui(new Ui::ResultItem)
|
|
|
|
|
|
{
|
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
|
|
|
|
// 强制应用样式表 - 这是关键!
|
|
|
|
|
|
this->setAttribute(Qt::WA_StyledBackground, true);
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化时设置样式
|
|
|
|
|
|
setItemStyle();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ResultItem::~ResultItem()
|
|
|
|
|
|
{
|
|
|
|
|
|
delete ui;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ResultItem::setResultData(int targetIndex, const ThreadPosition& position)
|
|
|
|
|
|
{
|
2026-01-27 20:43:12 +08:00
|
|
|
|
// 根据类型设置显示文本(带序号)
|
|
|
|
|
|
QString typeStr;
|
|
|
|
|
|
if (position.type == ThreadPosType::ThreadHead) {
|
|
|
|
|
|
typeStr = QString("%1-线头").arg(position.groupIndex);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
typeStr = QString("%1-下刀").arg(position.groupIndex);
|
|
|
|
|
|
}
|
|
|
|
|
|
ui->result_id->setText(typeStr);
|
2026-01-22 12:57:54 +08:00
|
|
|
|
|
|
|
|
|
|
// 设置数据到对应的Label控件
|
|
|
|
|
|
ui->result_x->setText(QString("%1").arg(position.x, 0, 'f', 2));
|
|
|
|
|
|
ui->result_y->setText(QString("%1").arg(position.y, 0, 'f', 2));
|
|
|
|
|
|
ui->result_z->setText(QString("%1").arg(position.z, 0, 'f', 2));
|
|
|
|
|
|
ui->result_angle->setText(QString("%1°").arg(position.roll, 0, 'f', 2));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ResultItem::setItemStyle()
|
|
|
|
|
|
{
|
2026-01-27 20:43:12 +08:00
|
|
|
|
// 紧凑样式,间隔由QListWidget的spacing控制
|
2026-01-22 12:57:54 +08:00
|
|
|
|
this->setStyleSheet(
|
|
|
|
|
|
"ResultItem { "
|
2026-01-27 20:43:12 +08:00
|
|
|
|
" border: 1px solid #3B3D47; "
|
|
|
|
|
|
" margin: 0px; "
|
|
|
|
|
|
" padding: 0px; "
|
2026-01-22 12:57:54 +08:00
|
|
|
|
"} "
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|