【文件属性】:
文件名称:一个超简单的FIFO在QT里验证了
文件大小:22KB
文件格式:ZIP
更新时间:2022-05-05 15:40:09
QT FIFO
用下标操作的环形
FIFOunsigned int rdex=0;
unsigned int wdex=0;
#define rwmax 10
void MainWindow::on_PutMessage_clicked()
{
QString debugstring("Write@");
if(((wdex+1)%rwmax)==rdex)//满
{
// debugstring=debugstring+" None";
}else
{
wdex++;
if(wdex>=rwmax)wdex=0;
unsigned char ysdex=0;//原来的下标
debugstring=debugstring+"["+QString::number((wdex>0)?(wdex-1):(rwmax-1))+"] +1--> "+QString::number(wdex);
}
//if(wdex>=rwmax)wdex=0;
ui->tEdit->append(debugstring);
}
void MainWindow::on_SendMessage_clicked()
{
QString debugstring("Read @");
if(rdex!=wdex)//不空
{
rdex++;
if(rdex>=rwmax)rdex=0;
debugstring=debugstring+"["+QString::number((rdex>0)?(rdex-1):(rwmax-1))+"] +1--> "+QString::number(rdex);
}else
{
// debugstring=debugstring+" None";
}
ui->tEdit->append(debugstring);
//if(rdex>=rwmax)rdex=0;
}
【文件预览】:
SerialPort
----mainwindow.ui(13KB)
----SerialPort.pro.user.c47cb93(18KB)
----SerialPort.pro.user.bd87a45(23KB)
----mainwindow.cpp(21KB)
----main.cpp(183B)
----SerialPort.pro(405B)
----SerialPort.pro.user.5af8ba9(18KB)
----mainwindow.h(2KB)
----SerialPort.pro.user(23KB)
----SerialPort.pro.user.6cdbe99(23KB)
----SerialPort.pro.user.1180f37(23KB)
----newdialog.h(305B)