?? mainwindow.cpp
字號:
#include <qlabel.h>
#include <qpushbutton.h>
#include <QVBoxLayout>
#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("test.jpeg")){
//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) : QMainWindow(parent)
{
counter = 0;
QVBoxLayout *vbox;
vbox = new QVBoxLayout(this);
msg = new QLineEdit("SERIAL PROGRAMMING",this);
msg->resize(50,50);
vbox->addWidget(msg);
pix = new QPixmap();
btn = new QPushButton(this);
btn->setText("GO!"); vbox->addWidget(btn);
QApplication::connect(btn,SIGNAL(clicked()),this,SLOT(serialOperate()));
btn2LoadImg = new QPushButton(this);
btn2LoadImg->setText("LOAD"); vbox->addWidget(btn2LoadImg);
lab = new QLabel("before load jpeg"); vbox->addWidget(lab);
QApplication::connect(btn2LoadImg,SIGNAL(clicked()),this,SLOT(loadJPEGFile()));
//btn->resize(100,75);
};
void MainWindow::setMsgText(char* txt){
QString msgs(txt);
QString count = QString::number(counter,10);
msgs.append(count);
const char *re = msgs.toAscii ();
//strcat(msgs,);
msg->setText(re);
};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -