[Qt-creator] What are advantages to have Core plugin over MainWindow?!?

Eike Ziller Eike.Ziller at qt.io
Wed Aug 15 12:55:31 CEST 2018



> On 15. Aug 2018, at 11:15, Christian Gagneraud <chgans at gmail.com> wrote:
> 
> On 15 August 2018 at 20:43, Eike Ziller <Eike.Ziller at qt.io <mailto:Eike.Ziller at qt.io>> wrote:
>> 
>> 
>>> On 14. Aug 2018, at 21:40, Szyk Cech <szykcech at spoko.pl> wrote:
>>> 
>>> Hi
>>> I just read some docs "Extending Qt Creator Manual" and study qt-creator/src/app/main.cpp file. And I have question (maybe not very wise but important to me):
>>> 
>>> What are advantages to have Core plugin over MainWindow?!?
>>> 
>>> I mean MainWindow class which handle whole app skeleton (located in main app exe module).
>>> 
>>> One reason for core plugin, from my point of view is that core plugin is shared object which can easily share its methods to other plugins - I think it is possible for exe (app exe module), but counter intuitive and cumbersome, and platform specific.
>>> 
>>> There are some more reasons for create Core plugin?
>> 
>> Handling it as just another plugin has the advantage that it uses the exact same startup, shutdown, building, linking, .... semantics as anything else. No need to invent something else :)
> 
> Really? like QtCreator's main() doesn't have special handling for the
> core plugin...
> Last time I checked, the core plugin was loaded explicitly and require
> (lot of) hand-crafted initialisation. If Core plugin is "just" another
> plugin, why it is not loaded as a result of being the root dependency
> of every other plugins?

main() does not explicitly load the Core plugin, and does not do anything with the Core plugin except checking for its existence and that it loaded successfully after  PluginManager::loadPlugins()
Yes, in that single way the Core plugin is special. But nevertheless the Core plugin is loaded because it is available in the plugin paths, not because of any special actions in main().

The special code in main() handles things that need to be done before creating a QApplication, or before using the PluginManager:

- setting up QSettings, since settings can also affect the plugin manager
- setting up plugin search paths
- setting application attributes that need to be set before creating a QApplication
- setting up translations
- passing command line arguments to an already running instance (instead of starting another instance) if -client is used

> I understand Eike's point of view, but I agree with Szyk, the 'Core'
> plugin could very well be managed as a 'Core' Library.

We would need special handling for the “core” parts of Qt Creator of at least
- startup and shutdown
- delayed intialization
- versioning and checks if a plugin can be loaded for this version of Qt Creator
- command line arguments like “-color”, “-theme”, “-presentationMode”, and files to open

All this is done exactly like for any Qt Creator plugin.

> QtCreator will refuse to start without it. This IMHO contradicts the
> very definition of a plugin.
> 
> Having say that, QtCreator is awesome, and it's even more awesome to
> be able to study its source code (and criticise it! ;)), I believe
> that many of us have learned a lot of things by studying it's
> architecture, at least I did.
> Thanks again.
> 
> Chris
> 
> PS: I remember reading some (old) slides that started with "QtCreator
> is actually just a plugin loader" or something along these lines.
> 
>> 
>> --
>> Eike Ziller
>> Principal Software Engineer
>> 
>> The Qt Company GmbH
>> Rudower Chaussee 13
>> D-12489 Berlin
>> eike.ziller at qt.io <mailto:eike.ziller at qt.io>
>> http://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
>> 
>> _______________________________________________
>> Qt-creator mailing list
>> Qt-creator at qt-project.org <mailto:Qt-creator at qt-project.org>
>> http://lists.qt-project.org/mailman/listinfo/qt-creator <http://lists.qt-project.org/mailman/listinfo/qt-creator>
-- 
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