QT圓形圖像剪切功能實(shí)現(xiàn)
更新時(shí)間:2022年10月21日 11:28:18 作者:江鳥(niǎo)木又
這篇文章主要介紹了QT圓形圖像剪切,實(shí)現(xiàn)代碼包括剪切代碼,完整QML源碼,C++代碼,代碼簡(jiǎn)單易懂,對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

剪切代碼:
Rectangle{
id:idRectRound
width: 250
height: 250
radius: width/2
anchors.centerIn: parent
color: "#ff00ff"
visible: false
}
Image {
id: idRectImg
width: 250
height: 250
anchors.centerIn: parent
source: "qrc:/res/demo.png"
visible: false
smooth: true
}
OpacityMask {
anchors.fill: idRectRound
source: idRectImg
maskSource: idRectRound
}完整QML源碼
import QtQuick 2.12
import QtQuick.Window 2.12
import QtGraphicalEffects 1.0
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
color:"black"
Rectangle{
id:idRectRound
width: 250
height: 250
radius: width/2
anchors.centerIn: parent
color: "#ff00ff"
visible: false
border.color: "yellow"
border.width: 2
}
Image {
id: idRectImg
anchors.centerIn: parent
source: "qrc:/res/demo.png"
visible: false
smooth: true
}
OpacityMask {
anchors.fill: idRectRound
source: idRectImg
maskSource: idRectRound
}
}C++代碼:
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
return app.exec();
}到此這篇關(guān)于QT圓形圖像剪切的文章就介紹到這了,更多相關(guān)qt圖像剪切內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
您可能感興趣的文章:
相關(guān)文章
C++深入探究哈希表如何封裝出unordered_set和unordered_map
哈希表是一種根據(jù)關(guān)鍵碼去尋找值的數(shù)據(jù)映射結(jié)構(gòu),該結(jié)構(gòu)通過(guò)把關(guān)鍵碼映射的位置去尋找存放值的地方,說(shuō)起來(lái)可能感覺(jué)有點(diǎn)復(fù)雜,我想我舉個(gè)例子你就會(huì)明白了,最典型的的例子就是字典2022-06-06
C語(yǔ)言實(shí)現(xiàn)BMP圖像處理(彩色圖轉(zhuǎn)灰度圖)
這篇文章主要為大家詳細(xì)介紹了C語(yǔ)言實(shí)現(xiàn)BMP圖像處理,彩色圖轉(zhuǎn)灰度圖,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-10-10
vscode+platformIO開(kāi)發(fā)stm32f4的實(shí)現(xiàn)
這篇文章主要介紹了vscode+platformIO開(kāi)發(fā)stm32f4的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-05-05
C++實(shí)現(xiàn)LeetCode(48.旋轉(zhuǎn)圖像)
這篇文章主要介紹了C++實(shí)現(xiàn)LeetCode(48.旋轉(zhuǎn)圖像),本篇文章通過(guò)簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-07-07

