Results 1 to 3 of 3

Thread: How to tell Creator about files that are not C++ files

  1. #1
    Join Date
    Jun 2019
    Location
    Tucson, AZ USA
    Posts
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default How to tell Creator about files that are not C++ files

    I have some files in my C++ project that are other than .cpp or .h files. One is an .ini file; others have to do with my code generation.

    How do I tell Creator about these files so they show up on the navigator panel so that I can edit them?

    To have .cpp files show up, I code these in the .pro file: SOURCE+=...; for .h files, HEADERS+=...

    I have coded DISTFILES+=... in the .pro file which causes things to show up in the Navigator, but I'm certain that's an incorrect usage of DISTFILES.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,474
    Thanked 274 Times in 269 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to tell Creator about files that are not C++ files

    It is correct. After using "Add existing file" to project and select an INI file Qt Creator creates DISTFILES rule in pro file.

  3. #3
    Join Date
    Jun 2019
    Location
    Tucson, AZ USA
    Posts
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to tell Creator about files that are not C++ files

    Quote Originally Posted by Lesiok View Post
    It is correct. After using "Add existing file" to project and select an INI file Qt Creator creates DISTFILES rule in pro file.
    I just found this here (I edited the typos):

    Qt Code:
    1. DISTFILES: Something special for Unix you won't use in most cases. From the docs:
    2. Specifies a list of files to be included in the dist target. This feature is supported by UnixMake specs only.
    3.  
    4. OTHER_FILES: Files, that are part of you project, but not of the "build". This can be things like a readme, build hints, or any other stuff, that does not fit into any other categories
    5.  
    6. RESOURCES: .qrc-files, that will be compiled into the application.
    7.  
    8. Regarding the usage of those three with QML: You can basically use DISTFILES or OTHER_FILES for other files. In QtCreator they appear in a node as other files. These two are exchangeable for most developers. The Qt examples are local project, thus either they don't require a resource or have both, i.e. you can find the QML-files in for example OTHER_FILES and RESOURCES.
    9.  
    10. For QML-files, you should always use RESOURCES, to make sure they are within your binary.
    To copy to clipboard, switch view to plain text mode 

    The description of DISTFILES above is straight out of the Qt manual https://doc.qt.io/qt-5/qmake-variable-reference.html#distfiles. That description says nothing about Qt Explorer. And there is no mention of OTHER_FILES in the Qt documentation, nor how to have files show up in Qt Explorer. I would consider this a bug in the documentation, wouldn't you?


    Added after 17 minutes:


    When you add a plain text file using OTHER_FILES or DISTFILES, the editor still thinks its a C++ file, so it gives warning messages in the editor. To eliminate the warning messages, do the following:

    Select Tools/Options/Environment/MIME Types.
    Find "text/plain" on the list.
    Edit the pattern of file names to include yours, e.g., *.txt;*.asc;*.dbt
    Press APPLY or OK to save the changes.

    The editor will no longer think you xxx.dbt files are C++ and the warnings will go away.
    Last edited by doug9f; 29th January 2020 at 18:27.

  4. The following user says thank you to doug9f for this useful post:

    d_stranz (31st January 2020)

Similar Threads

  1. Replies: 0
    Last Post: 13th September 2017, 15:29
  2. Adding .bin .rules and .ini files in qt creator
    By ftl_embedded in forum Qt Programming
    Replies: 3
    Last Post: 11th September 2015, 14:21
  3. Replies: 3
    Last Post: 25th April 2015, 10:09
  4. Qt Creator Qt Creator hang with certain source files
    By grayfox in forum Qt Tools
    Replies: 2
    Last Post: 23rd January 2015, 09:00
  5. Creator and DEF files
    By qtYoda in forum Qt Tools
    Replies: 18
    Last Post: 3rd June 2011, 22:13

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.