Results 1 to 3 of 3

Thread: Trying to make qmake PRINT the chars "<" and ">".

  1. #1
    Join Date
    Jun 2008
    Posts
    17
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Trying to make qmake PRINT the chars "<" and ">".

    Hiho there,

    I am trying to write a header file when qmake is executed and I can't make it write the characters "<" and ">".
    More detailed, I would (simplified) like qmake to write following lines in a file called "test.hpp" for example!
    As I am stuck at Qt4, I can't use the function "write_file", so my way would be to use "system()" instead, which works fine.

    Qt Code:
    1. ...
    2. H = $$LITERAL_HASH
    3. line01 = "$${H}ifndef TEST_HPP"
    4. line02 = "$${H}define TEST_HPP"
    5. line03 = "\n"
    6. line04 = "$${H}include <QString>"
    7. line05 = "\\n"
    8. line06 = "$${H}endif //TEST_HPP"
    9.  
    10. ...
    11. system(echo $${line01} > test.hpp)
    12. system(echo $${line02} >> test.hpp)
    13. system(echo $${line03} >> test.hpp)
    14. system(echo $${line04} >> test.hpp)
    15. system(echo $${line05} >> test.hpp)
    16. system(echo $${line06} >> test.hpp)
    17. ...
    To copy to clipboard, switch view to plain text mode 

    As long as I include those two characters, the file is not containing "line04".
    The other minor problem is that I can't also create the empty line, as in "line03" and "line05". Backslash and double backslash doesn't work here!
    But I could live without that if the include would work properly!
    So, if you know the way, please enlighten me too... And if you know a better way of creating that file, please feel free to point this out.

    Thanks in advance!

    freeman_w

  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: Trying to make qmake PRINT the chars "<" and ">".

    Have you tried:
    Qt Code:
    1. system(echo "$${line01}" > test.hpp)
    2. system(echo "$${line02}" >> test.hpp)
    3. system(echo "$${line03}" >> test.hpp)
    4. system(echo "$${line04}" >> test.hpp)
    5. system(echo "$${line05}" >> test.hpp)
    6. system(echo "$${line06}" >> test.hpp)
    To copy to clipboard, switch view to plain text mode 

  3. #3
    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: Trying to make qmake PRINT the chars "<" and ">".

    Didn't work when I tried it.

    If you are trying to write, for example, an include file containing defines for stuff only the build system knows then you could look at QMAKE_SUBSTITUTES paired with template files:
    Qt Code:
    1. // test.hpp.in
    2. #ifndef TEST_HPP
    3. #define TEST_HPP
    4.  
    5. #include <QString>
    6.  
    7. #define MYAPPVERSION '"$$VERSION"'
    8. #define MYSPECIALVAR '"$$MY_SPECIAL_VAR"'
    9.  
    10. #endif //TEST_HPP
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. # test.pro
    2. ...
    3. MY_SPECIAL_VAR = stuff
    4. QMAKE_SUBSTITUTES += test.hpp.in
    5. ...
    To copy to clipboard, switch view to plain text mode 

    to get this file generated when qmake is run:
    Qt Code:
    1. // test.hpp
    2. #ifndef TEST_HPP
    3. #define TEST_HPP
    4.  
    5. #include <QString>
    6.  
    7. #define MYAPPVERSION "1.0.0"
    8. #define MYSPECIALVAR "stuff"
    9.  
    10. #endif //TEST_HPP
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 1
    Last Post: 20th November 2015, 11:02
  2. Replies: 3
    Last Post: 16th March 2015, 08:31
  3. Replies: 3
    Last Post: 15th February 2010, 18:27
  4. Replies: 3
    Last Post: 8th July 2008, 20:37
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 20:05

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.