QML用Qt.labs.settings实现保存用户设置
Qt 实现 设置 用户 保存 settings qml Labs
2023-09-11 14:19:24 时间
举个简单的例子:
main.cpp中设置程序信息
QGuiApplication::setApplicationName("Gallery");
QGuiApplication::setOrganizationName("QtProject");
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
在需要保存设置的qml中:
...
import Qt.labs.settings 1.0
...{
...
Settings {
id: settings
property string input: "Default"
}
TextInput{
width:200
height: 50
id: textInput
text: settings.input
}
Button{
anchors.top:textInput.bottom
text:"save"
onClicked: {
settings.input=textInput.text
}
}
...
}
程序关闭后,再次启动时信息还会在文本框内。
相关文章
- Qt-Qt之实现框选地图功能(返回选中区域经纬度)
- Qt利用QPainter自绘实现热感应图效果
- qt QProcess
- Qt开源作品10-代码统计组件
- Qt编写地图综合应用33-雨量分布
- Qt利用ffmpeg实现音视频同步
- Qt查找对话框的功能实现
- Qt QSlider介绍(属性设置、信号、实现滑块移动到鼠标点击位置)
- Qt自定义只读模型
- C++QT实现TCP通信
- Qt之实现移动物体(稳定版)
- 使用linuxdeployqt在linux下进行Qt打包发布(超详细)
- 解决Ubuntu系统安装QT出错的问题:qt.qpa.plugin: Could not load the Qt platform plugin “xcb“ in ““ even though it
- Qt调用python有参和无参方法,取方法返回值
- Qt实现截图保存功能
- Using Qt to build an Omi App for iOS (and Android)
- QT打印窗口、退出、设置字体及颜色、设置时间、控件实现系统函数、添加资源文件(菜单图片)、工具栏添加图片