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. How to add the current time into Qt Creator files template?
Forum Updated to NodeBB v4.3 + New Features

How to add the current time into Qt Creator files template?

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
2 Posts 1 Posters 541 Views
  • 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.
  • B Offline
    B Offline
    bogong
    wrote on last edited by bogong
    #1

    Hello all!

    The issue: I need to add current timestamp into the file templates and get an ability to get it automatically at time of file creation. Is there system variables that will be used for the time inside of templates?

    This not working

    %YEAR%: Year
    %MONTH%: Month
    %DAY%: Day of the month
    %DATE%: Date
    %USER%: User name
    %FILENAME%: File name
    %CLASS%: Class name (if applicable)
    %$VARIABLE%: Contents of environment variable VARIABLE.
    

    There are for example file.cpp template from Qt Creator

    %{Cpp:LicenseTemplate}\
    #include "%{HdrFileName}"
    %{JS: Cpp.openNamespaces('%{Class}')}
    @if '%{IncludeQSharedData}'
    class %{CN}Data : public QSharedData
    {
    public:
    
    };
    

    Is there specially defined variable %{Time} that might be used to auto-timestamp in this template?

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bogong
      wrote on last edited by
      #2

      Solution found. Through JS implementation to template file. Something like this:

      %{JS: 
      	var time = new Date();
      	time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
      }
      
      1 Reply Last reply
      3

      • Login

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