当前位置:网站首页>QT function optimization: QT 3D gallery
QT function optimization: QT 3D gallery
2022-07-28 19:05:00 【Yunxi Zhihua】
Qt Function optimization :Qt 3D Gallery
List of articles
One 、 design sketch
As shown in the figure below :
Two 、 Use steps
1. .pro part
The code is as follows :
TEMPLATE = app
QT += qml quick
CONFIG += c++11
SOURCES += main.cpp
RESOURCES += qml.qrc \
image.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# Default rules for deployment.
qnx: target.path = /tmp/$${
TARGET}/bin
else: unix:!android: target.path = /opt/$${
TARGET}/bin
!isEmpty(target.path): INSTALLS += target
2. .qml part
Demo.qml
The code is as follows :
import QtQuick 2.0
import QtGraphicalEffects 1.0
Rectangle {
id:coverflow
property ListModel model
property int itemCount: 5
PathView{
id:pathView
model:coverflow.model
delegate: Item {
id:delegateItem
width: 530
height: 420
z:PathView.iconZ
scale:PathView.iconScale
Image{
id:image
source: url
width: delegateItem.width
height: delegateItem.height
}
ShaderEffect {
anchors.top: image.bottom
width: image.width
height: image.height;
anchors.left: image.left
property variant source: image;
property size sourceSize: Qt.size(0.5 / image.width, 0.5 / image.height);
fragmentShader:
"varying highp vec2 qt_TexCoord0;
uniform lowp sampler2D source;
uniform lowp vec2 sourceSize;
uniform lowp float qt_Opacity;
void main() {
lowp vec2 tc = qt_TexCoord0 * vec2(1, -1) + vec2(0, 1);
lowp vec4 col = 0.25 * (texture2D(source, tc + sourceSize) + texture2D(source, tc- sourceSize)
+ texture2D(source, tc + sourceSize * vec2(1, -1))
+ texture2D(source, tc + sourceSize * vec2(-1, 1)));
gl_FragColor = col * qt_Opacity * (1.0 - qt_TexCoord0.y) * 0.2;
}"
}
transform: Rotation{
origin.x:image.width/2.0
origin.y:image.height/2.0
axis{
x:0;y:1;z:0}
angle: delegateItem.PathView.iconAngle
}
}
path:coverFlowPath
pathItemCount: coverflow.itemCount
anchors.fill: parent
preferredHighlightBegin: 0.5
preferredHighlightEnd: 0.5
}
Path{
id:coverFlowPath
startX: 0
startY: coverflow.height/3
PathAttribute{
name:"iconZ";value: 0}
PathAttribute{
name:"iconAngle";value: 70}
PathAttribute{
name:"iconScale";value: 0.6}
PathLine{
x:coverflow.width/2;y:coverflow.height/3}
PathAttribute{
name:"iconZ";value: 100}
PathAttribute{
name:"iconAngle";value: 0}
PathAttribute{
name:"iconScale";value: 1.0}
PathLine{
x:coverflow.width;y:coverflow.height/3}
PathAttribute{
name:"iconZ";value: 0}
PathAttribute{
name:"iconAngle";value: -70}
PathAttribute{
name:"iconScale";value: 0.6}
PathPercent{
value:1.0}
}
}
main.qml
The code is as follows :
import QtQuick 2.8
import QtQuick.Window 2.2
Window {
visible: true
width:1800
height: 880
title: qsTr(" Lingmou ")
ListModel{
id:model
ListElement{
url:"qrc:/image/1.png"}
ListElement{
url:"qrc:/image/2.png"}
ListElement{
url:"qrc:/image/3.png"}
ListElement{
url:"qrc:/image/4.png"}
ListElement{
url:"qrc:/image/6.png"}
ListElement{
url:"qrc:/image/7.png"}
ListElement{
url:"qrc:/image/8.png"}
ListElement{
url:"qrc:/image/9.png"}
ListElement{
url:"qrc:/image/10.png"}
ListElement{
url:"qrc:/image/11.png"}
ListElement{
url:"qrc:/image/12.png"}
ListElement{
url:"qrc:/image/13.png"}
ListElement{
url:"qrc:/image/14.png"}
}
CoverFlow{
anchors.fill:parent
model:model
}
}
3. .cpp part
main.cpp
The code is as follows :
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}
summary
The above is part of Qt About function optimization ——Qt Function optimization :Qt 3D The complete code part of the gallery , Attached separately Qt Function optimization :Qt 3D Gallery complete material and code compression package , Users can also be Directly follow wechat official account : Yunxi Zhihua , reply “3D Gallery ”, Free access to . meanwhile , All the relevant Qt Part of interface optimization , All in the column below ——Qt Function optimization in , If you are interested, you can watch and use , I hope these articles can make everyone's Qt The software is more beautiful and perfect !!!
another , If you have time , It can also be found in the column section of the personal home page , Check out my Qt Practical column And Qt Interface optimization Column , There are Qt Relevant actual combat software and relatively practical auxiliary functions , If you are interested, please have a look at (๑><๑)
Attached separately Qt actual combat : Yunxi chat room and Qt Interface optimization : Double click the mouse effect Two related articles , You can slide down to the column at the bottom of the article , See other articles in related columns , I hope I can help you , Thank you for your support ~( ̄▽ ̄~)~
边栏推荐
- Is it easy to learn the zero foundation of software testing?
- Meta Q2 earnings: revenue fell for the first time, and metaverse will compete with apple
- ECS 5 workflow
- 3、 Uni app fixed or direct to a certain page
- 2、 Uni app login function page Jump
- Live broadcast platform software development, JS implementation by alphabetical order
- 【雷达】基于核聚类实现雷达信号在线分选附matlab代码
- 112. Use the self-developed proxy server to solve the cross domain access error encountered when uploading files by SAP ui5 fileuploader
- 使用自开发的代理服务器解决 SAP UI5 FileUploader 上传文件时遇到的跨域访问错误试读版
- Cause analysis and solution of video jam after easycvr is connected to the device
猜你喜欢

CTR click through rate prediction practice project of advertising recommendation!

How to solve the problem that easycvr device cannot be online again after offline?

GC garbage collector details

零知识证明:具有DDH假设的 ZKP

Xiaobai must see the development route of software testing

Getting started with gateway

QT & OpenGL lighting

Configuration tutorial: how does the organizational structure of the new version of easycvr (v2.5.0) cascade to the superior platform?

1、 My first wechat applet

我的创作纪念日 -- 2022年7月25日
随机推荐
Is it useful to learn software testing?
数字经济时代的开源数据库创新 | 2022开放原子全球开源峰会数据库分论坛圆满召开
EasyCVR接入设备后播放视频出现卡顿现象的原因分析及解决
Is the software testing training institution reliable?
11 年膨胀 575 倍,微信为何从“小而美”变成了“大而肥”?
Getting started with QT & OpenGL
AI has changed thousands of industries. How can developers devote themselves to the new "sound" state of AI voice
QT with line encoding output cout
QT - CPP database operation
Win11电脑摄像头打开看不见,显示黑屏如何解决?
ECS 5 workflow
Mongodb database shell command execution
Kotlin:sealed Class detailed explanation of sealed class
LeetCode_ 1137_ Nth teponacci number
Full analysis of warehouse building on the lake: how to build a lake warehouse integrated data platform | deepnova technology collection series open class phase IV
What if svchost.exe of win11 system has been downloading?
Introduction and advanced level of MySQL (I)
Xiaobai must see the development route of software testing
112. 使用自开发的代理服务器解决 SAP UI5 FileUploader 上传文件时遇到的跨域访问错误
[actual combat] realize page distortion correction with OpenCV