Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Creating a custom project wizard in Qt Creator
Servers for Qt installer are currently down

Creating a custom project wizard in Qt Creator

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
3 Posts 2 Posters 938 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    robbydrive
    wrote on 6 Mar 2017, 22:37 last edited by
    #1

    Hello everybody,

    I'm writing because got really stuck with creating a custom project wizard, particularly adding new item in 'New file or project...' menu section.

    I took some thoughts from here, some pieces from documentation and some other resources with relatively fresh info.

    The main idea I have been trying to implement up until now is to create new class in some way derived from IWizardFactory (tried directly derived, derived from BaseFileWizardFactory, from CustomProjectWizard and CustomWizardMetaFactory), add it to the PluginManager pool (with addAutoReleasedObject) and according to the documentation PM will do the rest.

    Adding to the PM pool - no problem, I can see it from printing names of objects from PM pool.
    But adding entry to the menu doesn't happen and my factory doesn't show up in the output of IWizardFactory::allWizardFactories.

    The question is: what am I missing/doing wrong? My code of the latest attempt is below:

    SomeProjectWizardFactory.h

    #include <projectexplorer/customwizard/customwizard.h>
    #include "Someprojectwizard.h"
    
    class SomeProjectWizardFactory : public ProjectExplorer::CustomWizardMetaFactory<SomeProjectWizard>
    {
      Q_OBJECT
    public:
      SomeProjectWizardFactory();
    };
    

    SomeProjectWizardFactory.cpp

    #include "Someprojectwizard.h"
    
    SomeProjectWizardFactory::SomeProjectWizardFactory()
      : ProjectExplorer::CustomWizardMetaFactory<SomeProjectWizard>(Core::IWizardFactory::ProjectWizard)
    {}
    

    SomeProjectWizard.h

    #include <projectexplorer/customwizard/customwizard.h>
    
    class SomeProjectWizard : public ProjectExplorer::CustomProjectWizard
    {
      Q_OBJECT
    public:
      SomeProjectWizard();
    };
    

    SomeProjectWizard.cpp

    #include "Someprojectwizard.h"
    
    SomeProjectWizard::SomeProjectWizard()
      : ProjectExplorer::CustomProjectWizard()
    {
      setDisplayName("Some");
      setCategory("Some");
      setDescription("Some description");
      setDisplayCategory("Some");
      setId(Core::Id("Some.Id"));
    }
    

    SomePlugin.cpp

    bool SomePlugin::initialize(const QStringList &arguments, QString *errorString)
    {
        ...
        SomeProjectWizard *factory = new SomeProjectWizard();
        addAutoReleasedObject(factory);
        ...
    
    1 Reply Last reply
    0
    • R Offline
      R Offline
      robbydrive
      wrote on 8 Mar 2017, 19:43 last edited by
      #2

      After some research I found the answer to my problem.

      The key point is that after this commit what is written on the IWizardFactory documentation page is not applicable anymore as now you should use following code to register your custom project wizard:

      // someplugin.cpp, someplugin::initialize
      Core::IWizardFactory::registerFactoryCreator([]() -> QList<Core::IWizardFactory *> {
          return QList<Core::IWizardFactory *> { new SomeProjectWizard };
        });
      

      I believe that IWizardFactory documentation page should be updated :)

      1 Reply Last reply
      2
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 8 Mar 2017, 21:59 last edited by
        #3

        Hi and welcome to devnet,

        You can check the bug report system and open a bug report against the Qt Creator project for that.

        Even better, if you know where the missing documentation should, you could consider providing a patch for Qt Creator's sources.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0

        1/3

        6 Mar 2017, 22:37

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved