QT串口编程
QT串口编程.txt男人偷腥时的智商仅次于爱因斯坦。美丽让男人停下,智慧让男人留下。任何东西都不能以健康做交换。QT串口编程
[serial.cpp]
#include
#include
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc,argv);
MainWindow m;
a.setMainWidget(&m);
m.show();
return a.exec();
}
[mainwindow.h]
#ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H
#include
class QLabel;
class QPushButton;
class QLineEdit;
class QPixmap;
class SerialThread;
class MainWindow:public QMainWindow {
Q_OBJECT
public:
MainWindow(QWidget * parent = 0, const char * name= 0) ;
~MainWindow(){};
void setCounter(int no);
void setMsgText(char* txt);
public slots:
void serialOperate();
void loadJPEGFile();
protected:
void paintEvent( QPaintEvent * );
private:
QLineEdit *msg;
QPushButton *btn;
QPushButton *btn2LoadImg;
QPixmap *pix;
QLabel *lab;
SerialThread *a;
int counter;
};
#endif
[mainwindow.cpp]
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "mainwindow.h"
#include "serialthread.h"
void MainWindow::paintEvent( QPaintEvent * )
{
QPainter paint( this );
paint.drawLine( 0,0,500,500 ); // draw line
paint.drawPixmap(0,0,*pix);
}
void MainWindow::loadJPEGFile(){
if(!pix->load("testjpeg")){
//if(!pix->load("circle")){
setMsgText("Load failed");
return;
}
setMsgText("Load success!");
update();
}
void MainWindow::setCounter(int no){
counter = no;
}
void MainWindow::serialOperate(){
a = new SerialThread(this);
a->start();
a->wait();
}
MainWindow::MainWindow(QWidget * parent , const char * name)
:QMainWindow(parent, name)
{
counter = 0;
QVBox *vbox;
vbox = new QVBox(this);
vbox->resize(300,150);
//msg = new QLabel("SERIAL PROGRAMMING",vbox);
msg = new QLineEdit("SERIAL PROGRAMMING",vbox);
msg->resize(300,50);
pix = new QPixmap();
btn = new QPushButton(vbox);
btn->setText("GO!");
QApplication::connect(btn,SIGNAL(clicked()),this,SLOT(serialOperate()));
btn2LoadImg = new QPushButton(vbox);
btn2LoadImg->setText("LOAD");
lab = new QLabel("before load jpeg",vbox);
QApplication::connect(btn2LoadImg,SIGNAL(clicked()),this,SLOT(loadJPEGFile()));
//btn->resize(100,75);
//vbox->show();
};
void MainWindow::setMsgText(char* txt){
QString msgs(txt);
QString count = QString::number(counter,10);
msgs.append(count);
const char *re = msgs.asc
QT串口编程_日语学习_外语学习_教育专区。QT串口编程 精心收集的绝佳文档 全部免积分 欢迎下载QT???±à??.txt QT???±à?? [serial.cpp] #include #inclu...
QT串口编程.txt QT串口编程 [serial.cpp] #include #include #include "mainwindow.h" int main(int argc, char *argv[]) { QApplication a(argc,argv); ...
QT串口编程 9页 免费 QT 编程 42页 1财富值 QT编程 25页 5财富值 qt核心编程 29页 免费 Qt编程问题 4页 2财富值 QT编程进阶 29页 2财富值 16_QT编程...
Qt串口通信专题教程_信息与通信_工程科技_专业资料。Qt串口通信实例... Qt编写串口通信程序 19页 1下载券 Linux下Qt编程入门 38页 1下载券...
qt下串口开发Demo【新手入手推荐】!_IT/计算机_专业资料。串口Demo... QT串口编程 3页 免费 QT简单的文本查看器教程... 10页 免费 ubuntu下安装...
Qt串口通信教程_IT/计算机_专业资料。Qt串口通信教程yafeilinux Qt 3 > http://www.yafeilinux.com ( : windows xp Qt Creator Linux ) Qt qextserialport...
Qt编写串口通信程序全程图文讲解_计算机软件及应用_IT/计算机_专业资料。Qt编写串口通信程序全程图文讲解Qt 编写串口通信程序全程图文讲解 首先说明我们的编程环境是 ...
qt 串口 实现代码_信息与通信_工程科技_专业资料。主要参考网上的教程,但是多... QT串口编程 7页 免费 线程+定时实现linux下的... 5页 免费 QT代码 暂无...
QT 串口与 51 单片机通信 通过这个小例子主要想说明 QT 怎样进行线程编程的思想,实例如图,好吧,下面是过程 上一个例子我们采用的是手工编写代码的方法,这个例子...
【更新】(2010.12)Qt编写串口通信程序全程图文讲解_计算机软件及应用_IT/...下面我们将讲述详细编程过程,这里我们先给出完整的程序,然后再进行逐句分析。 1....
热门文档