Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to use checkbox in wizard.json for template design



  • Hi All,

    I'm designing a template, in which I want to include checkbox and based on the status of that checkbox I want to do something. So below are some codes which I tried,

    Below is checkbox code

    {
    	"name": "UnitTest",
    	"trDisplayName": "Unit Test",
    	"type": "CheckBox",
    	"data":
    	{
    		"checkedValue": "Test",
    		"checked": "%{JS: ('%{TestCB}' === 'Test')? 'yes':''}",
    		"uncheckedValue": ""
    	}
    },
    

    Now, If I dont checked the box then it should not create the file,

    "generators":
        [
            {
                "typeId": "File",
                "data":
                [
    	       {
    		    "conditions": "%{JS: '%{checked}' === 'yes'}",
                        "source": "../UnitTest/file.pro",
                        "target": "%{ProFileNameUT}",
                        "openAsProject": true
                    }
    	     ]
             }
         ]
    

    So can some one help me what "conditions" I have to put so that it'll not generate file if box is not checked ?

    Thanking you all,

    With Regards,
    Nitin P.



  • Re: How to use checkbox in wizard.json for template design

    Hello Guys,
    I got the solution, so I think to put reply which may be helpful for others too.
    If you compare the codes with above you'll find the changes.

    {
    	"name": "UnitTest",
    	"trDisplayName": "Unit Test",
    	"type": "CheckBox",
    	"data":
    	{
    		"checked": false
    	}
    },
    
    "generators":
        [
            {
                "typeId": "File",
                "data":
                [
    	       {
    		    "condition": "%{UnitTest}",
                        "source": "../UnitTest/file.pro",
                        "target": "%{ProFileNameUT}",
                        "openAsProject": true
                    }
    	     ]
             }
         ]
    

    Hope that help someone.



  • Re: How to use checkbox in wizard.json for template design

    Hello Guys,
    I got the solution, so I think to put reply which may be helpful for others too.
    If you compare the codes with above you'll find the changes.

    {
    	"name": "UnitTest",
    	"trDisplayName": "Unit Test",
    	"type": "CheckBox",
    	"data":
    	{
    		"checked": false
    	}
    },
    
    "generators":
        [
            {
                "typeId": "File",
                "data":
                [
    	       {
    		    "condition": "%{UnitTest}",
                        "source": "../UnitTest/file.pro",
                        "target": "%{ProFileNameUT}",
                        "openAsProject": true
                    }
    	     ]
             }
         ]
    

    Hope that help someone.


Log in to reply