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

剪切代碼:
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();
}到此這篇關于QT圓形圖像剪切的文章就介紹到這了,更多相關qt圖像剪切內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
C++深入探究哈希表如何封裝出unordered_set和unordered_map
哈希表是一種根據(jù)關鍵碼去尋找值的數(shù)據(jù)映射結(jié)構(gòu),該結(jié)構(gòu)通過把關鍵碼映射的位置去尋找存放值的地方,說起來可能感覺有點復雜,我想我舉個例子你就會明白了,最典型的的例子就是字典2022-06-06
C語言實現(xiàn)BMP圖像處理(彩色圖轉(zhuǎn)灰度圖)
這篇文章主要為大家詳細介紹了C語言實現(xiàn)BMP圖像處理,彩色圖轉(zhuǎn)灰度圖,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-10-10
vscode+platformIO開發(fā)stm32f4的實現(xiàn)
這篇文章主要介紹了vscode+platformIO開發(fā)stm32f4的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-05-05
C++實現(xiàn)LeetCode(48.旋轉(zhuǎn)圖像)
這篇文章主要介紹了C++實現(xiàn)LeetCode(48.旋轉(zhuǎn)圖像),本篇文章通過簡要的案例,講解了該項技術(shù)的了解與使用,以下就是詳細內(nèi)容,需要的朋友可以參考下2021-07-07

