void Shelfscreen::updateSlot() { for (int loopc=0; loopc<elements.size(); loopc++) { delete elements[loopc].image; delete elements[loopc].text; } elements.clear(); for (int loopc=0; loopc<bookshelf->numBooks(); loopc++) { Mobi * mobi = bookshelf->getBook(loopc); ShelfElement element; element.text = new QPushButton(mobi->getFullName()); element.text->setObjectName("titlebutton"); element.text->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); connect(element.text, SIGNAL(clicked()), this, SLOT(readSlot())); element.image = new QLabel(); QImage qi = mobi->bookCover(); qi = qi.scaled(120, 120, Qt::KeepAspectRatio); element.image->setPixmap(QPixmap::fromImage(qi)); layout->addWidget(element.image, loopc, 0); layout->addWidget(element.text, loopc, 1); layout->setRowStretch(loopc, 1); element.book = mobi; elements.push_back(element); } layout->addWidget(quit_button, bookshelf->numBooks(), 1); layout->setRowStretch(bookshelf->numBooks(), 1); update(); }
infarredsimulation::infarredsimulation(QWidget *parent) : QWidget(parent), ui(new Ui::infarredsimulation) { ui->setupUi(this); setWindowFlags(Qt::FramelessWindowHint); movie =new QMovie(":/images/red.gif"); ui->label->setMovie(movie); // people=new QPixmap(":/people.png"); //movie->start(); //生成一张位图 QBitmap objBitmap(size()); //QPainter用于在位图上绘画 QPainter painter(&objBitmap); //填充位图矩形框(用白色填充) painter.fillRect(rect(),Qt::white); painter.setBrush(QColor(0,0,0)); //在位图上画圆角矩形(用黑色填充) painter.drawRoundedRect(this->rect(),10,10); //使用setmask过滤即可 setMask(objBitmap); setMinimumWidth(850); setMinimumHeight(600); this->isPortOpen=false; serialport=new QSerialPort; if(isPortOpen){ //停止读取数据 readTimer.stop(); serialport->close(); this->isPortOpen=false; } else { //设置设备号 foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) { serialport->setPortName(info.portName()); } serialport->open(QIODevice::ReadWrite); serialport->setBaudRate(9600); //设置数据位 serialport->setDataBits((QSerialPort::DataBits)(8)); //设置停止位 serialport->setStopBits((QSerialPort::StopBits)(1)); //校验 serialport->setParity((QSerialPort::Parity)(0));//23333333 this->isPortOpen=true; char send[2]={0x09,0xff}; serialport->write(send); readTimer.start(200);//每隔2ms connect(&readTimer,SIGNAL(timeout()),this,SLOT(readSlot())); //连接设备 }
Client::Client(QString ipAddress, int port, QObject *parent): QObject(parent), mTcpSocket(0), mIpAddress(ipAddress), mPort(port) { mTcpSocket = new QTcpSocket(this); connect(mTcpSocket, SIGNAL(readyRead()), this, SLOT(readSlot())); connect(mTcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayErrorSlot(QAbstractSocket::SocketError))); std::cout << "Connecting to ip: " << mIpAddress.toStdString() << " port: " << mPort << std::endl; mTcpSocket->connectToHost(mIpAddress, mPort); }
buttonDemonstrate::buttonDemonstrate(QWidget *parent) : QWidget(parent), ui(new Ui::buttonDemonstrate) { ui->setupUi(this); setWindowFlags(Qt::FramelessWindowHint); QBitmap objBitmap(size()); //QPainter用于在位图上绘画 QPainter painter(&objBitmap); //填充位图矩形框(用白色填充) painter.fillRect(rect(),Qt::white); painter.setBrush(QColor(0,0,0)); //在位图上画圆角矩形(用黑色填充) painter.drawRoundedRect(this->rect(),10,10); //使用setmask过滤即可 setMask(objBitmap); this->isPortOpen=false; serialport = new QSerialPort; this->isPortOpen=false; serialport=new QSerialPort; if(isPortOpen){ //停止读取数据 readTimer.stop(); serialport->close(); this->isPortOpen=false; } else { //设置设备号 foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) { serialport->setPortName(info.portName()); } serialport->open(QIODevice::ReadWrite); serialport->setBaudRate(4800); //设置数据位 serialport->setDataBits((QSerialPort::DataBits)(8)); //设置停止位 serialport->setStopBits((QSerialPort::StopBits)(1)); //校验 serialport->setParity((QSerialPort::Parity)(0));//23333333 this->isPortOpen=true; char send[2]={0x12,0xff}; serialport->write(send); readTimer.start(200);//每隔2ms connect(&readTimer,SIGNAL(timeout()),this,SLOT(readSlot())); //连接设备 }
/** Author: Joel Denke Description: Reads data from buffers and run it */ int runData(int i) { char * elem = malloc(sizeof(char) * MESSAGE_SIZE); SDL_mutexP(b_lock[i]); if (!slotsEmpty(cb[i])) { elem = readSlot(cb[i]); printf("Get data %s from slot %d\n", elem, i+1); if (elem != NULL) { runEvent(i+1, elem); } } SDL_mutexV(b_lock[i]); }
} serialport->open(QIODevice::ReadWrite); serialport->setBaudRate(9600); //设置数据位 serialport->setDataBits((QSerialPort::DataBits)(8)); //设置停止位 serialport->setStopBits((QSerialPort::StopBits)(1)); //校验 serialport->setParity((QSerialPort::Parity)(0));//23333333 this->isPortOpen=true; char send[2]={0x01,0xff}; serialport->write(send); readTimer.start(200);//每隔2ms waitTimer.start(3000);//每3s } connect(&readTimer,SIGNAL(timeout()),this,SLOT(readSlot())); connect(&waitTimer,SIGNAL(timeout()),this,SLOT(judgeSlot())); } ledsimulation::~ledsimulation() { delete ui; } void ledsimulation::readSlot(){ QByteArray data; data=this->serialport->readAll(); if(!isFrame(data,0x01,3)){ return; }
serialport->open(QIODevice::ReadWrite); serialport->setBaudRate(9600); //设置数据位 serialport->setDataBits((QSerialPort::DataBits)(8)); //设置停止位 serialport->setStopBits((QSerialPort::StopBits)(1)); //校验 serialport->setParity((QSerialPort::Parity)(0));//23333333 this->isPortOpen=true; readTimer.start(200);//每隔200ms } connect(&readTimer,SIGNAL(timeout()),this,SLOT(readSlot())); //********************************************************************************* connect(ui->pushButton_2,SIGNAL(on_pushButton_2_clicked()),this,SLOT(readSlot())); //********************************************************************************* } Complex::~Complex() { delete ui; } void Complex::readSlot(){ QByteArray data; QTimer *timer_2 = new QTimer(); //E:\briup_gif