[Qt-creator] Configure script file path in QtCreator options and read it in plugin code

Eike Ziller Eike.Ziller at qt.io
Fri Dec 15 13:24:21 CET 2017



> On 15. Dec 2017, at 11:51, Vidhya Arun <svidhyapria at gmail.com> wrote:
> 
> Hi
> 
>  I was able to successfully add a custom option under Tools-Options of QtCreator. I have a text box added in my custom page here to accept a parameter.
> 
> But I would like to retain the value once entered and given an apply/Ok. Currently every time I open the Tools-Options, the textbox is blank always. Is there a way to save the once entered input in settings to avoid entering input everytime ?

Core::ICore::settings()->setValue(“MyPlugin/MySetting”, m_mySetting)

either on IOptionsPage::apply, or at your plugin’s shutdown, or connected to the Core::ICore::saveSettingsRequested() signal (use Core::ICore::instance() as the originating object).

And on your plugin’s startup (e.g. at the time of MyPlugin::initialize()) read the setting again with 

m_mySetting = Core::ICore::settings()->value(“MyPlugin/MySetting”)

Br, Eike

> On Tue, 12 Dec 2017 at 6:19 PM, Vidhya Arun <svidhyapria at gmail.com> wrote:
> Thanks, I'll check it out.
> 
> On Tue, 12 Dec 2017 at 1:38 PM, Eike Ziller <Eike.Ziller at qt.io> wrote:
> 
> 
> > On 12. Dec 2017, at 07:40, Vidhya Arun <svidhyapria at gmail.com> wrote:
> >
> > Hello
> 
> Hi,
> 
> >
> > I have a Qt creator plugin written where a perl script is called to perform the required functionality. The perl script is located in a specific path in my linux machine and there is a parameter passed to it. Currently I am invoking this perl script with the hardcoded path and parameter directly from my plugin. Whenever there is a change in the path or parameter of the perl script, my plugin code also got to be changed.
> >
> > Is there a possibility where I can configure the perl script path in some Tools-options of Qtcreator and read this path directly from plugin ? This will ensure plugin code remains untouched for any changes in perl script.
> 
> Core::ICore::settings() returns a QSettings object that works on the Qt Creator settings (on Linux located at ~/.config/QtProject/QtCreator.ini). You can use that in your plugin to write and read any settings, also custom ones for your plugin.
> If you want to add a page to Tools > Options, have a look at the Core::IOptionsPage class (<coreplugin/dialogs/optionspage.h>) and how it is used in the other plugins.
> 
> Br, Eike
> 
> --
> Eike Ziller
> Principal Software Engineer
> 
> The Qt Company GmbH
> Rudower Chaussee 13
> D-12489 Berlin
> eike.ziller at qt.io
> http://qt.io
> Geschäftsführer: Mika Pälsi,
> Juha Varelius, Mika Harjuaho
> Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B
> 

-- 
Eike Ziller
Principal Software Engineer

The Qt Company GmbH
Rudower Chaussee 13
D-12489 Berlin
eike.ziller at qt.io
http://qt.io
Geschäftsführer: Mika Pälsi,
Juha Varelius, Mika Harjuaho
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B



More information about the Qt-creator mailing list