?? mainwindow.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); };
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -