1 Star 0 Fork 0

qinxude/rk3568ui

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
bblistscreen.cpp 5.11 KB
一键复制 编辑 原始数据 按行查看 历史
qinxude 提交于 2024-09-03 09:38 . 3568ui base
#include "bblistscreen.h"
#include "ui_bblistscreen.h"
BBListScreen::BBListScreen(QWidget *parent) :
QWidget(parent),
ui(new Ui::BBListScreen)
{
ui->setupUi(this);
this->hide();
QStringList headerLabels = QStringList()<<QObject::tr("发现时间")
<<QObject::tr("设备号")
<<QObject::tr("对方回转值");
//ui->ListWidget->setRowCount(15);
ui->ListWidget->setColumnCount(3);
ui->ListWidget->setColumnWidth(0,350);
ui->ListWidget->setColumnWidth(1,250);
ui->ListWidget->setColumnWidth(2,200);
ui->ListWidget->setShowGrid(false);
//ui->ListWidget->setColumnWidth(4,115);
ui->ListWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->ListWidget->setHorizontalHeaderLabels(headerLabels);
ui->ListWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->ListWidget->setFrameShape(QFrame::NoFrame);
ui->ListWidget->setRowHeight(0, 40);
ui->ListWidget->setShowGrid(true);
ui->ListWidget->verticalHeader()->setHidden(true);
ui->ListWidget->verticalScrollBar();
ui->ListWidget->horizontalHeader()->setFont(QFont("song", 24));
ui->ListWidget->setStyleSheet("QTableWidget::item{border:1px solid ;\
border-bottom-color:rgb(255,255,255);\
color:rgb(255,255,255)}");
QFont font = ui->ListWidget->horizontalHeader()->font();
font.setBold(true);
ui->ListWidget->horizontalHeader()->setFont(font);
ui->ListWidget->horizontalHeader()->setStyleSheet("QHeaderView::section{background:rgb(85, 87, 83);}");
CleanListItem();
m_SearchTimer = new QTimer;
m_SearchTimer->setInterval(3000);
m_DataDictionary = DataDictionary::GetInstance();
connect(m_DataDictionary,SIGNAL(MisDataChange(MisDataIndex_t)),\
this,SLOT(MisDataChange(MisDataIndex_t)));
connect(m_SearchTimer,SIGNAL(timeout()),\
this,SLOT(SearchTimeout()));
}
BBListScreen::~BBListScreen()
{
delete ui;
}
void BBListScreen::showEvent(QShowEvent *event)
{
on_SearchButton_clicked();
}
void BBListScreen::CleanListItem()
{
for(int i = 0 ;i < ui->ListWidget->rowCount() ;i++)
{
ui->ListWidget->removeRow(i);
}
}
void BBListScreen::on_QuiteButton_clicked()
{
this->hide();
}
void BBListScreen::MisDataChange(MisDataIndex_t Index)
{
switch (Index) {
case MIS_BLKBOX_SEARCH_TOWER_RES:
{
QList<struct SearchData> List;
m_DataDictionary->GetMisData(Index,List);
if(List.count() != 0){
AddListItem(List);
ui->Info->setText("");
}else{
ui->Info->setText("未搜索到设备");
}
m_SearchTimer->stop();
}
break;
default:
break;
}
}
void BBListScreen::SearchTimeout()
{
m_SearchTimer->stop();
ui->Info->setText("搜索超时");
}
void BBListScreen::AddListItem(QList<struct SearchData> &list)
{
for (int i = 0;i < list.size();i++) {
struct SearchData Info = list.at(i);
QString Time = QDateTime::fromSecsSinceEpoch(Info.Time).toString("yyyy-MM-dd hh:mm:ss");
AddListItem(Time,\
QString().number(Info.DevId),\
QString().number(Info.CurAng));
}
}
void BBListScreen::AddListItem(QString Time,QString Id,QString Ang)
{
//QString Time = QDateTime::fromMSecsSinceEpoch(Date.toLongLong()).toString("yyyy-MM-dd hh:mm:ss");
int32_t CurRow = ui->ListWidget->rowCount();
ui->ListWidget->setRowCount(CurRow + 1);
QTableWidgetItem* item0 = new QTableWidgetItem(Time);
item0->setFlags(Qt::NoItemFlags);
item0->setFont(QFont("song", 20));
QFont font = item0->font();
font.setBold(true);
item0->setFont(font);
QTableWidgetItem* item1 = new QTableWidgetItem(Id,5);
item1->setFlags(Qt::NoItemFlags);
item1->setFont(QFont("song", 20));
font = item1->font();
font.setBold(true);
item1->setFont(font);
QTableWidgetItem* item2 = new QTableWidgetItem(Ang,5);
item2->setFlags(Qt::NoItemFlags);
item2->setFont(QFont("song", 20));
font = item2->font();
font.setBold(true);
item2->setFont(font);
ui->ListWidget->setItem(CurRow, 0, item0);
ui->ListWidget->setItem(CurRow, 1, item1);
ui->ListWidget->setItem(CurRow, 2, item2);
ui->ListWidget->setRowHeight(CurRow,50);
ui->ListWidget->item(CurRow, 0)->setTextAlignment(Qt::AlignCenter);
}
void BBListScreen::ClearAllListItem()
{
//QString Time = QDateTime::fromMSecsSinceEpoch(Date.toLongLong()).toString("yyyy-MM-dd hh:mm:ss");
while(ui->ListWidget->rowCount())
{
QTableWidgetItem* item0 = ui->ListWidget->itemAt(0,0);
delete item0;
QTableWidgetItem* item1 = ui->ListWidget->itemAt(0,1);
delete item1;
QTableWidgetItem* item2 = ui->ListWidget->itemAt(0,2);
delete item2;
ui->ListWidget->removeRow(0);
}
}
void BBListScreen::on_SearchButton_clicked()
{
ui->Info->setText("搜索中 ... ...");
ClearAllListItem();
m_SearchTimer->start();
m_DataDictionary->SetMisData(MIS_BLKBOX_SEARCH_TOWER,1);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/qinxude/rk3568ui.git
[email protected]:qinxude/rk3568ui.git
qinxude
rk3568ui
rk3568ui
master

搜索帮助