zoukankan      html  css  js  c++  java
  • QML用Qt.labs.settings实现保存用户设置

    举个简单的例子:
    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{
            200
            height: 50
            id: textInput
            text: settings.input
        }
        Button{
            anchors.top:textInput.bottom
            text:"save"
            onClicked: {
                settings.input=textInput.text
            }
        }
       ...
    }
    

    程序关闭后,再次启动时信息还会在文本框内。

  • 相关阅读:
    hdoj 1002 A + B Problem II
    hdoj 1234 开门人和关门人
    hdoj 2203 亲和串
    nyoj 73 比大小
    81B
    信息传递
    bzoj1787
    最少交换次数
    100803C
    火柴排队
  • 原文地址:https://www.cnblogs.com/flipped/p/6743131.html
Copyright © 2011-2022 走看看