QT settings example

# -*- coding: utf-8 -*-
##  Copyright 2019 Trevor van Hoof and Jan Pijpers.
##  Licensed under the Apache License, Version 2.0
##  Downloaded from https://janpijpers.com or https://gumroad.com/janpijpers
##  See the license file attached or on https://www.janpijpers.com/script-licenses/

'''
Name: qtSettingExample
Description:

Simple example on how to use qt settings.

The first time you run it, it will say you dint have a last opened project, and set an example path
the second time it will print the value of the example path.


'''

from PySide.QtCore import QSettings ## pip install PySide


if __name__ =="__main__":

    settings = QSettings("Company Name", "Tool Name")

    ## Check if the value already exsited
    stored = settings.value("lastOpenedProject")
    if stored:
        print "We have a last opened project: ", stored
    else:
        print "We dint have a last opened project. Setting the example path."
        ## Saven die bende
        settings.setValue("lastOpenedProject", "C:/some/example.path")

    print "Press enter to exit"
    raw_input()

Leave a Reply

Your email address will not be published.