开发环境
操作系统:uBuntu 20.04.3
Qt版本:Qt6.22 LTS
问题描述:
最近由于项目使用了一个较好的Linux屏,终于可以使用Qt6了,刚好前段时间发布了Qt6.22 LTS版,昨天在ubuntu下安装了Qt6.22,安装步骤记录在
https://editor.csdn.net/md/?articleId=121802956
我个人使用Qt,QML布局的文件,文件名使用.ui.qml,事件响应,js等操作的文件,使用.qml。其中布局文件,我喜欢用Creator自带的Design来做设计。
然而,在使用Qt6时发现,QtCreator6左边导航栏上的Design按钮是灰色的,无法使用,如下图所示。
注:工程为 Qt Quick Application(即使用QML做UI)
后在查找后发现,Qt6默认插件中,并未使能Designer,只要在Help->About plugins->Qt Quick下将QmlDesigner勾选后重启QtCreater即可。
效果如下:
import QtQuick
Rectangle {
id: __rect
width: 200
height: 200
state: "blue"
states: [
State {
name: "blue"
PropertyChanges {
target: __rect
color: "blue"
radius: 20
}
},
State {
name: "red"
PropertyChanges {
target: __rect
color: "red"
radius: 50
}
},
State {
name: "yellow"
PropertyChanges {
target: __rect
color: "yellow"
radius: 100
}
}
]
}