⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainwindow.cpp

📁 基于qt的串口多线程编程
💻 CPP
字号:
#include <qlabel.h>     #include <qpushbutton.h>  #include <qvbox.h> #include <qapplication.h>#include <qlineedit.h>#include <qpixmap.h>#include <qpainter.h>#include <qimage.h>#include <qstring.h>  #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("/root/serial/bin/1.JPG")){     //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.ascii ();                  //strcat(msgs,);        msg->setText(re);     };

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -