Results 1 to 7 of 7

Thread: Qt Creator Changing the default C++ Class template

  1. #1
    Join Date
    Jun 2012
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Qt Creator Changing the default C++ Class template

    Hi I'm trying to find where the template is kept for the C++ class so I can edit the header and the implementation file to include some other bits and pieces, but I can't seem to locate them. I've found the other wizards as described http://doc.qt.io/qt-4.8/http://doc.qt.nokia.com/qtcreator-2.4/creator-project-wizards.html but I can't find the class wizard there. Does anyone know where it might be.
    Thanks.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt Creator Changing the default C++ Class template

    You can include a licence template to be included at the top of new h and cpp files using Tools > Options > C++ > File Naming.

    On my Linux box there are buckets of templates under: /usr/share/qtcreator/templates
    I am sure you can find the equivalent location on your platform.

  3. #3
    Join Date
    Jun 2012
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt Creator Changing the default C++ Class template

    This is where I was expecting to find it but as far as I can tell its not there.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt Creator Changing the default C++ Class template

    How have you installed Qt Creator? Part of the Qt SDK... then look under {path to}/QtSDK/QtCreator/share/qtcreator/templates.

    Failing that, open a shell and type:
    Qt Code:
    1. locate -b qt4project
    2. # OR
    3. find / -type d -name qt4project
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jun 2012
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt Creator Changing the default C++ Class template

    Sorry I should have been clearer the file exists, and QtCreator is installed. The problem is none of the files in templates or the sub folders appear to relate to the new class template.

  6. #6
    Join Date
    Sep 2008
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt Creator Changing the default C++ Class template

    I also wanted to know this, since I much prefer having `#pragma once` to the old and hacky #include guards.

    Unfortunately it is all hard-coded so you would need to recompile QtCreator to change the template:

    https://qt.gitorious.org/qt-creator/...izard.cpp#L199

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt Creator Changing the default C++ Class template

    At least those "old and hacky" include guards are guaranteed to work everywhere unlike the non-standard "#pragma once". Feel free to propose the patch to make this either fully templated or optionally use the pragma.

Similar Threads

  1. Template class problem
    By lni in forum Qt Programming
    Replies: 1
    Last Post: 12th June 2012, 19:25
  2. Replies: 4
    Last Post: 25th June 2010, 10:21
  3. Template of ingredient class
    By Trok in forum Qt Programming
    Replies: 2
    Last Post: 21st August 2009, 13:27
  4. Replies: 0
    Last Post: 8th July 2009, 09:12
  5. Template class
    By steg90 in forum General Programming
    Replies: 15
    Last Post: 12th June 2007, 21:49

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.