Results 1 to 3 of 3

Thread: Reading content from a file in qmake

  1. #1
    Join Date
    Jan 2011
    Location
    Piteå, Sweden
    Posts
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11

    Default Reading content from a file in qmake

    We're using Pococapsule to define a configuration XML file which will eventually end up in a .cpp file which contains factories for the various classes. This XML file contains references to other modules' XML files like this:

    Qt Code:
    1. <!DOCTYPE poco-application-context
    2. SYSTEM "http://www.pocomatic.com/poco-application-context.dtd" [
    3. <!ENTITY ModuleX SYSTEM "../../ModuleX/conf/ModuleX.xml" >
    4. <!ENTITY ModuleY SYSTEM "../../ModuleY/conf/ModuleY.xml" >
    5. <!ENTITY ModuleZ SYSTEM "../../ModuleZ/conf/ModuleZ.xml" >
    6. ]>
    To copy to clipboard, switch view to plain text mode 

    When any of these or the master XML file is touched the .cpp file needs to be rebuilt. I already have it working for the master XML file but I'm having problems trying to figure out how to extract the individual includes and add them to the dependency list. My first thought was to extract the contents of the XML file using the undocumented cat function but I can't get that to work

    Qt Code:
    1. # Hard coded for test
    2. CONFIGCONTENT = cat(/path/to/ModuleX.xml)
    3. message($$CONFIGCONTENT)
    To copy to clipboard, switch view to plain text mode 

    This only prints the actual command (cat /....) and not the file's content. Am I missing something here or is there some better way of doing this? I want to try to avoid external programs since it will be built on multiple platforms.
    Last edited by MarcoAlanen; 23rd March 2011 at 08:29.

  2. #2
    Join Date
    Jan 2011
    Location
    Piteå, Sweden
    Posts
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11

    Default Re: Reading content from a file in qmake

    Solved the problem with cat. I need to do $$cat(..) and not cat(..).
    Now I just need to solve a regexp in find to extract the path. No luck yet

  3. #3
    Join Date
    May 2010
    Posts
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11
    Wiki edits
    11

    Default Re: Reading content from a file in qmake

    For the record:

    The qmake contains(variablename,value) function will accept a regex pattern for the value parameter.

Similar Threads

  1. Replies: 11
    Last Post: 10th February 2011, 01:38
  2. Replies: 3
    Last Post: 29th December 2010, 18:14
  3. Problems reading content of QFile
    By martinn in forum Newbie
    Replies: 12
    Last Post: 6th April 2010, 19:42
  4. set content(&file)
    By rk0747 in forum Qt Programming
    Replies: 1
    Last Post: 6th February 2010, 09:31
  5. Saving QLabel content in a file
    By Caius Aérobus in forum Newbie
    Replies: 1
    Last Post: 29th October 2008, 18:03

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.