資源簡介
QT繪圖是學習QT必不可少的技能,以下是畫圖的簡單實現,僅供需要的人士參考。
代碼片段和文件信息
#include?“Form.h“
Form::Form(QWidget?*parent):QWidget(parent)
{???oldx=0;oldy=0;//用來記錄前一坐標(xy)
????this->setAttribute(Qt::WA_NoBackground);
????bDrawing=false;
????curShape=Ellipse;
????this->resize(800600);//初始化兩個緩沖區
????bufferImage=QImage(this->width()this->height()
???????????????????????QImage::Format_ARGB32_Premultiplied);//bufferImage用來存儲最終的圖形
????bufferImage.fill(qRgb(255255255));
????tempImage=QImage(this->width()this->height()
?????????????????????QImage::Format_ARGB32_Premultiplied);//tempImage是臨時緩沖區
}
void?Form::setImage(QString?fileName)//打開文件
{
????this->clear();
????bufferImage.load(fileName);
????this->update();
}
void?Form::saveImage(QString?fileName)//保存文件
{
????QImage?saveFile(fileName“bmp“);
????saveFile=QImage(this->width()thi
- 上一篇:網絡協議數據包
- 下一篇:操作系統的實驗作業之文件管理
評論
共有 條評論