中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁(yè) > news >正文

揚(yáng)州公司做網(wǎng)站公司手游推廣平臺(tái)代理

揚(yáng)州公司做網(wǎng)站公司,手游推廣平臺(tái)代理,科技進(jìn)步是國(guó)防強(qiáng)大的重要的保證,做設(shè)計(jì)在哪個(gè)網(wǎng)站找圖片大全一、QPainter繪圖 繪圖事件 void paintEvent() 聲明一個(gè)畫家對(duì)象,OPainter painter(this) this指定繪圖設(shè)備 畫線、畫圓、畫矩形、畫文字 設(shè)置畫筆QPen 設(shè)置畫筆寬度、風(fēng)格 設(shè)置畫刷QBrush 設(shè)置畫刷風(fēng)格 代碼示例: #includ…

一、QPainter繪圖

繪圖事件????????void paintEvent()
聲明一個(gè)畫家對(duì)象,OPainter painter(this)????????this指定繪圖設(shè)備
畫線、畫圓、畫矩形、畫文字
設(shè)置畫筆QPen????????設(shè)置畫筆寬度、風(fēng)格

設(shè)置畫刷QBrush????????設(shè)置畫刷風(fēng)格

代碼示例:

#include "widget.h"
#include "ui_widget.h"
#include<QPainter>//畫家類Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui->setupUi(this);
}void Widget::paintEvent(QPaintEvent *){//實(shí)例化畫家對(duì)象  this指定的是繪圖的設(shè)備QPainter painter(this);//設(shè)置畫筆QPen pen(QColor(255,0,0));//設(shè)置畫筆風(fēng)格pen.setStyle(Qt::DotLine);//設(shè)置畫筆寬度pen.setWidth(3);//讓畫家使用這個(gè)筆painter.setPen(pen);//設(shè)置畫刷-->填充顏色QBrush brush(Qt::cyan);//設(shè)置畫刷風(fēng)格brush.setStyle(Qt::Dense7Pattern);//讓畫家使用畫刷painter.setBrush(brush);//畫線painter.drawLine(QPoint(0,0),QPoint(100,100));//畫圓   橢圓painter.drawEllipse(QPoint(100,100),50,50);//畫矩形painter.drawRect(QRect(20,20,50,50));//畫文字painter.drawText(QRect(10,200,150,50),"好好學(xué)習(xí),天天向上");}Widget::~Widget()
{delete ui;
}

輸出如下所示:

?

二、QPainter高級(jí)設(shè)置

抗鋸齒????????效率低
painter.setRenderHint(QPainter::Antialiasing);

對(duì)畫家進(jìn)行移動(dòng)
????????painter.translate(100,0);

????????保存狀態(tài)save
????????還原狀態(tài)restore

代碼示例:?

#include "widget.h"
#include "ui_widget.h"
#include<QPainter>//畫家類Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui->setupUi(this);
}void Widget::paintEvent(QPaintEvent *){//高級(jí)設(shè)置///QPainter painter(this);
//     painter.drawEllipse(QPoint(100,50),50,50);
//     //設(shè)置抗鋸齒能力  效率低
//     painter.setRenderHint(QPainter::Antialiasing);
//     painter.drawEllipse(QPoint(200,50),50,50);//畫矩形painter.drawRect(QRect(20,20,50,50));//移動(dòng)畫家painter.translate(100,0);//保存畫家狀態(tài)painter.save();painter.drawRect(QRect(20,20,50,50));painter.translate(100,0);//還原畫家保存狀態(tài)painter.restore();painter.drawRect(QRect(20,20,50,50));}Widget::~Widget()
{delete ui;
}

三、手動(dòng)調(diào)用繪圖事件

如果想手動(dòng)調(diào)用繪圖事件利用update()
利用畫家畫圖片painter.drawPixmap( x, y,QPixmap(路飛))

widget.h

#ifndef WIDGET_H
#define WIDGET_H#include <QWidget>QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACEclass Widget : public QWidget
{Q_OBJECTpublic:Widget(QWidget *parent = nullptr);~Widget();//繪圖事件void paintEvent(QPaintEvent *);int posX = 0;private:Ui::Widget *ui;
};
#endif // WIDGET_H

widget.cpp?

#include "widget.h"
#include "ui_widget.h"
#include<QPainter>//畫家類Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui->setupUi(this);//點(diǎn)擊移動(dòng)按鈕,移動(dòng)圖片connect(ui->pushButton,&QPushButton::clicked,[=](){posX += 20;//如果要手動(dòng)調(diào)用繪圖事件 用update更新update();});
}void Widget::paintEvent(QPaintEvent *){///利用畫家 畫資源圖片//QPainter painter(this);//如果超出屏幕從0開(kāi)始if(posX > this->width()){posX = 0;}painter.drawPixmap(posX,0,QPixmap(":/image/Luffy.png"));}Widget::~Widget()
{delete ui;
}

輸出如下所示:(當(dāng)超出屏幕時(shí)從0開(kāi)始)

利用定時(shí)器讓其自動(dòng)從左到右移動(dòng):?

#include "widget.h"
#include "ui_widget.h"
#include<QPainter>//畫家類
#include<QTimer>Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui->setupUi(this);//點(diǎn)擊移動(dòng)按鈕,移動(dòng)圖片connect(ui->pushButton,&QPushButton::clicked,[=](){posX += 20;//如果要手動(dòng)調(diào)用繪圖事件 用update更新update();});//實(shí)現(xiàn)自動(dòng)讓圖片向右移動(dòng)QTimer *timer = new QTimer(this);timer->start(10);connect(timer,&QTimer::timeout,[=](){posX++;update();});
}void Widget::paintEvent(QPaintEvent *){///利用畫家 畫資源圖片//QPainter painter(this);//如果超出屏幕從0開(kāi)始if(posX > this->width()){posX = 0;}painter.drawPixmap(posX,0,QPixmap(":/image/Luffy.png"));}Widget::~Widget()
{delete ui;
}

四、繪圖設(shè)備

1. QPixmap Qlmage QBitmap(黑白色) QPicture Qwidget

2. QPixmap對(duì)不同平臺(tái)做了顯示的優(yōu)化
????????QPixmap pix( 300,300)
????????pix.fill(填充顏色)
????????利用畫家往pix 上畫畫? ? ? ? QPainter painter( & pix)

????????保存pix.save(“路徑")

3. Qimage可以對(duì)像素進(jìn)行訪問(wèn)
????????使用和QPixmap差不多 Qlmage img(300,300,Qlmage::Format_RGB32);

????????其他流程和QPixmap一樣
????????可以對(duì)像素進(jìn)行修改img.setPixel(i,j,value);

代碼示例:

#include "widget.h"
#include "ui_widget.h"
#include<QPixmap>
#include<QPainter>
#include<QImage>Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui->setupUi(this);//    //Pixmap繪圖設(shè)備 專門為平臺(tái)做了顯示的優(yōu)化
//    QPixmap pix(300,300);//    //填充顏色
//    pix.fill(Qt::white);//    //聲明畫家
//    QPainter painter(&pix);
//    painter.setPen(QPen(Qt::green));
//    painter.drawEllipse(QPoint(150,150),100,100);//    //保存
//    pix.save("D:\\QT\\pix.png");//QImage繪圖設(shè)備    可以對(duì)像素進(jìn)行訪問(wèn)QImage img(300,300,QImage::Format_RGB32);img.fill(Qt::white);QPainter painter(&img);painter.setPen(QPen(Qt::blue));painter.drawEllipse(QPoint(150,150),100,100);//保存img.save("D:\\QT\\img.png");
}Widget::~Widget()
{delete ui;
}

QPixmap和Qimage輸出如下所示為:

? ? ? ? ? ? ? ??

Qimage修改像素點(diǎn):

#include "widget.h"
#include "ui_widget.h"
#include<QPixmap>
#include<QPainter>
#include<QImage>Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui->setupUi(this);
}//繪圖事件
void Widget::paintEvent(QPaintEvent *event)
{QPainter painter(this);//利用QImage 對(duì)像素進(jìn)行修改QImage img;img.load(":/image/Luffy.png");//修改像素點(diǎn)for(int i = 50; i < 100; i++){for(int j = 50; j<100;j++){QRgb value = qRgb(255,0,0);img.setPixel(i,j,value);}}painter.drawImage(0,0,img);
}Widget::~Widget()
{delete ui;
}

輸出對(duì)比如下所示:?

? ? ?

4. QPicture記錄和重現(xiàn)繪圖指令

????????QPicture pic
????????painter.begin(&pic);
????????保存:pic.save(任意后綴名)

????????重現(xiàn):利用畫家可以重現(xiàn)????????painter.drawPicture(0,0,pic);

代碼示例:?

#include "widget.h"
#include "ui_widget.h"
#include<QPixmap>
#include<QPainter>
#include<QImage>
#include<QPicture>Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui->setupUi(this);//QPicture繪圖設(shè)備  可以記錄和重現(xiàn)繪圖指令QPicture pic;QPainter painter;painter.begin(&pic);//開(kāi)始往pic上畫painter.setPen(QPen(Qt::cyan));painter.drawEllipse(QPoint(150 ,150),100,100);painter.end();//結(jié)束畫畫//保存到磁盤pic.save("D:\\QT\\pic.zt");
}//繪圖事件
void Widget::paintEvent(QPaintEvent *event)
{QPainter painter(this);//重現(xiàn)繪圖指令QPicture pic;pic.load("D:\\QT\\pic.zt");painter.drawPicture(0,0,pic);
}Widget::~Widget()
{delete ui;
}

輸出如下所示:?

http://www.risenshineclean.com/news/31429.html

相關(guān)文章:

  • 奢侈品商城網(wǎng)站建設(shè)方案泰安做網(wǎng)站公司
  • 貴陽(yáng)市網(wǎng)站做的最好的識(shí)別關(guān)鍵詞軟件
  • asp網(wǎng)站亂碼百度推廣在線客服
  • 做文化建設(shè)的網(wǎng)站免費(fèi)做網(wǎng)站怎么做網(wǎng)站鏈接
  • 全球速賣通靠譜嗎seo的關(guān)鍵詞無(wú)需
  • 專業(yè)電商網(wǎng)站建設(shè)百度快照客服
  • 做vr效果圖的網(wǎng)站seo優(yōu)化關(guān)鍵詞
  • 深圳企業(yè)網(wǎng)站制作公司美國(guó)今天剛剛發(fā)生的新聞
  • 價(jià)格優(yōu)化網(wǎng)站建設(shè)百度快速收錄方法
  • 哈爾濱php網(wǎng)站開(kāi)發(fā)公司關(guān)鍵詞優(yōu)化的建議
  • 比優(yōu)化更好的詞是seo教程網(wǎng)站
  • 大連網(wǎng)站制作重慶百度推廣排名
  • 汕尾手機(jī)網(wǎng)站開(kāi)發(fā)一鍵注冊(cè)所有網(wǎng)站
  • psd做成網(wǎng)站電腦培訓(xùn)速成班多少錢
  • 二級(jí)域名是什么洛陽(yáng)網(wǎng)站seo
  • 免費(fèi)行情軟件app網(wǎng)站大全下載免費(fèi)入口資源鏈接搜索引擎
  • 國(guó)外免費(fèi)二級(jí)域名注冊(cè)網(wǎng)站各大搜索引擎提交入口
  • 環(huán)保公司網(wǎng)站模板聯(lián)合早報(bào) 即時(shí)消息
  • wordpress讀音seo的概念
  • 做胃鏡多少錢天津津門網(wǎng)站I南昌百度搜索排名優(yōu)化
  • 電子商務(wù)網(wǎng)站建設(shè)作文編寫網(wǎng)站
  • 背景視頻素材下載免費(fèi)seo搜索優(yōu)化
  • 學(xué)校網(wǎng)站建設(shè)計(jì)入哪個(gè)會(huì)計(jì)科目google chrome download
  • 做淘寶客網(wǎng)站需要多大空間seo外推軟件
  • 公司做網(wǎng)站收費(fèi)騰訊企點(diǎn)注冊(cè)
  • 什么網(wǎng)站可以快速做3d效果圖網(wǎng)站建設(shè)公司排行榜
  • 微信網(wǎng)站設(shè)計(jì)模板下載東莞新聞最新消息今天
  • 江門網(wǎng)站建設(shè)開(kāi)發(fā)日本進(jìn)口yamawa
  • 成品網(wǎng)站nike源碼1688網(wǎng)絡(luò)推廣團(tuán)隊(duì)哪家好
  • 朝陽(yáng)區(qū)社會(huì)建設(shè)工作室網(wǎng)站高效統(tǒng)籌疫情防控和經(jīng)濟(jì)社會(huì)發(fā)展