55 lines
1.5 KiB
C++
55 lines
1.5 KiB
C++
|
|
#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 RodPosition& position, const RodInfo& rodInfo)
|
|||
|
|
{
|
|||
|
|
// 设置目标编号
|
|||
|
|
ui->result_id->setText(QString("棒材:%1").arg(targetIndex));
|
|||
|
|
|
|||
|
|
// 设置坐标数据
|
|||
|
|
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_axial->setText(QString("(%1, %2, %3)")
|
|||
|
|
.arg(rodInfo.axialDirX, 0, 'f', 3)
|
|||
|
|
.arg(rodInfo.axialDirY, 0, 'f', 3)
|
|||
|
|
.arg(rodInfo.axialDirZ, 0, 'f', 3));
|
|||
|
|
|
|||
|
|
// 设置法向方向
|
|||
|
|
ui->result_normal->setText(QString("(%1, %2, %3)")
|
|||
|
|
.arg(rodInfo.normalDirX, 0, 'f', 3)
|
|||
|
|
.arg(rodInfo.normalDirY, 0, 'f', 3)
|
|||
|
|
.arg(rodInfo.normalDirZ, 0, 'f', 3));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void ResultItem::setItemStyle()
|
|||
|
|
{
|
|||
|
|
// 只设置右侧和下侧边框作为格子间分隔线,不修改背景和QLabel样式
|
|||
|
|
this->setStyleSheet(
|
|||
|
|
"ResultItem { "
|
|||
|
|
" border: 6px solid #191A1C; " // 边框
|
|||
|
|
" border-radius: 0px; " // 去掉圆角,让分隔线更清晰
|
|||
|
|
"} "
|
|||
|
|
);
|
|||
|
|
}
|