Results 1 to 6 of 6

Thread: Resource search/lookup tool/script to check completeness and correctness of qrc files

  1. #1
    Join Date
    Nov 2006
    Location
    Dresden, Germany
    Posts
    108
    Thanks
    9
    Thanked 12 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question Resource search/lookup tool/script to check completeness and correctness of qrc files

    Hi all,

    I have a large project with 200+ resource files (mostly pixmaps) and need to do refactoring/directory structure changes.

    Now my pixmaps are used all over the code base with typical qrc reference paths: ":/master/arrow_16x16/right/background/arrow_right_middle.png", both in cpps and ui-files.

    When I now modify my qrc file and move the referenced pixmaps in the directory structure, I have several situations:

    - pixmap is referenced in qrc and correctly used in the source code
    - source code contains invalid qrc-path (not detected at compile time, and difficult to find through testing)
    - pixmap is referenced in qrc but nowhere used (i.e. unused and could be deleted)
    - pixmap is in directory structure but not (yet) referenced in qrc (i.e. unused and could be deleted)

    Obviously, cases 2 to 4 are suboptimal, yet, it is very time consuming to detect such problems and clean out the code base and directory structure.

    Does anyone know of a tool/script that:

    - scans a base directory of resources
    - reads a project's qrc file (or files)
    - scans the source code (cpp and ui) for string constants with pattern ":/*.png" or any other suitable extension

    and then prints out a nice summary of all resources used and unused and files, i.e. the 4 categories above?

    Thanks for any suggestions,
    Andreas
    Last edited by ghorwin; 25th January 2022 at 07:57.
    Andreas

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,239
    Thanks
    303
    Thanked 865 Times in 852 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Resource search/lookup tool/script to check completeness and correctness of qrc f

    Does anyone know of a tool/script that:
    I don't know of a tool, but QRC files are basically XML so can be read and processed like any normal ASCII file. It probably would not be too hard to write a python program to 1) read each <file> entry from the QRC file, 2) verify that the file exists on disk (if needed), and 3) matches the use in a cpp / h file. For step 3, you could fire off grep with the filename as the target to match so you wouldn't have to write that part.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Nov 2006
    Location
    Dresden, Germany
    Posts
    108
    Thanks
    9
    Thanked 12 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Lightbulb Re: Resource search/lookup tool/script to check completeness and correctness of qrc f

    I agree - writing such a tool wouldn't be too hard. How about a challenge - how may hours of work will it take to get a decent tool written?

    It should:

    - generate a list of resources, categorized as described
    - clean out qrc-file(s) from unused resources
    - offer the functionality to remove unused pixmaps from directory structure

    My guess: 1-2 days, maybe faster.

    Questions:

    - Project name? "ResourceCleanser" or "QrcChecker" or ...
    - Programming language? Qt-Gui-Tool or Python command line tool?
    Andreas

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,239
    Thanks
    303
    Thanked 865 Times in 852 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Resource search/lookup tool/script to check completeness and correctness of qrc f

    Hah. It would have to be a weekend project for me. Since I am trying to teach myself Python, I would probably use that with PyQt. Probably QrcChecker would be a more descriptive name. I'll think about it.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  5. #5
    Join Date
    Nov 2006
    Location
    Dresden, Germany
    Posts
    108
    Thanks
    9
    Thanked 12 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Lightbulb Re: Resource search/lookup tool/script to check completeness and correctness of qrc f

    Not quite a weekend project (to many other projects), but done in a little less than 20 working hours.

    So, here it is: the first real QRC-Checker: https://github.com/ghorwin/QrcChecker

    Mind: this is a simple tool, only basic error checking included, but already with some convenience. Most of all, it does its job for me.

    As always, if you need anything special, just hack away. Since this is a tool for the Qt coding community, I didn't bother with creating installers and the like... just clone the repo, compile and be happy!

    PS: I'd appreciate (hopefully positive :-) ) feedback!
    Andreas

  6. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,239
    Thanks
    303
    Thanked 865 Times in 852 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Resource search/lookup tool/script to check completeness and correctness of qrc f

    My version is nearly done as well, in probably about the same amount of time. We can compare features once I have finished (probably next weekend).
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. How to build a search tool bar like Wireshark
    By leinad in forum Qt Programming
    Replies: 5
    Last Post: 31st January 2020, 17:59
  2. Replies: 1
    Last Post: 28th July 2016, 18:38
  3. how to run a vbs script in resource from inside QT
    By sherifomran in forum Qt Programming
    Replies: 2
    Last Post: 15th September 2013, 11:30
  4. Running a bash script from resource (qrc) file
    By onamatic in forum Qt Programming
    Replies: 4
    Last Post: 3rd February 2012, 10:09
  5. Image resource lookup in OS X
    By stipa in forum Qt Quick
    Replies: 1
    Last Post: 1st December 2010, 08:11

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.