首页 技术 正文
技术 2022年11月20日
0 收藏 714 点赞 4,051 浏览 1331 个字

1.QML编写可视化元素,运行后程序窗口上无显示。检查电脑的显卡是否支持OpenGL,如果支持请更新显卡驱动。

QQuickView 提供了一个窗体用于显示UI
    QQmlEngine 提供QML运行的环境
    QQuickWindow 显示窗体,以及对item对象的管理及用户交互

如果用 QQmlApplicationEngine,根节点必须是Window,否则无窗体显示

例如:

Rectangle {


    width:
    height:
    color: "red"
     visible: true
}Window {
 visible: true
    width:
    height:
    flags:"FramelessWindowHint"

    Rectangle {

    width:
    height:
    color: "red"
     visible: true
}
}

2.加载图片显示QML Image: Cannot open。解决在qml.qrc右击添加文件目录,把图片的文件夹添加进去。图片就能正常显示。

 Image{
id:image
width: parent.width
height: parent.height
source: "images/background.png"
}

3.组件,一个文件就是一个基础组件,一个以文件为基础的组件在文件中创建了一个QML元素,并且将文件以元素类型来命名(例如Button.qml)。你可以像任何其它的QtQuick模块中使用元素一样来使用这个组件。我们在根级导出了文本和点击信号。通常我们命名根元素为root让引用更加方便。我们使用了QML的alias(别名)的功能,它可以将内部嵌套的QML元素的属性导出到外面使用。有一点很重要,只有根级目录的属性才能够被其它文件的组件访问。

import QtQuick 2.0
//MyButton.qml
Item {
id: root
width: ; height: // export button properties
property alias text: label.text
signal clicked Rectangle {
anchors.fill: parent
color: "lightsteelblue"
border.color: "slategrey"
} Text {
id: label
anchors.centerIn: parent
text: "Start"
}
MouseArea {
anchors.fill: parent
onClicked: {
root.clicked()
}
}
}
import QtQuick 2.7
import QtQuick.Window 2.2
import QtMultimedia 5.5
import QtQuick.Controls 2.0//main.qmlWindow { visible: true
width:
height:
title: qsTr("Hello World") MyButton{
id:button
x:;y:
text:"Start"
onClicked: {
status.text="button clicked!"
}
} Text{
id:status
x:;y:
width: ;height:
text:"waiting..."
horizontalAlignment: Text.AlignVCenter
}}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,104
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,580
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,428
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,200
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,835
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,918