[Interest] #define in qml

henry.haverinen at nokia.com henry.haverinen at nokia.com
Tue Feb 21 17:55:02 CET 2012


On 2/20/12 10:47 AM, "ext Thiago Macieira" <thiago at kde.org> wrote:

>> > It's also possible to have different .qml files having slightly
>>different
>> > imports. You just can't mix major versions, because the backend
>>library is
>> > completely different.
>> 
>> I would also assume that it's necessary to have separate files for each
>> supported version. I can only speculate on how many there would be, but
>> my guess would be not too many. So it might not be a problem. If there
>> are a lot of them, it would become a maintainance nightmare.
>
>Indeed, separate files. The point is that you should not have to keep
>many 
>files. Once you're ready to upgrade (and require a new version), you do
>it and 
>don't look back. You don't keep two versions working.

Another common case for #ifdefs is configuration management in
cross-platform projects.
It's not always possible to port a project to a new platform and never
look back. :-)

In one of our Qt SDK user surveys, we asked how much people use non-Qt
APIs in their projects.
Only around 20-25% of projects were 100% Qt code, varying a bit between
target platforms. 
Here are the results for one random platform, Mac OS X (N = 287):

My application is 100% Qt Code: 20.6 %
  
Small part of my application uses nonĀ­-Qt APIs: 54.0 %
  
Significant part of my application uses non-Qt APIs: 17.1 %
I use Qt for a small part of my application only: 3.8 %


I know this data doesn't prove that #ifdefs are required, because maybe
some of the non-Qt APIs might be cross-platform, and maybe some of the
code that calls non-Qt non-cross-platform APIs can be separated out in
platform-specific source files. Anyways, cross-platform Qt C++ projects
often benefit from being able to have #ifdefs around some short snippets
inside a file.

I would expect some sort of conditional evaluation statement would be
useful in cross-platform Qt Quick projects too.

Cheers,
Henry



More information about the Interest mailing list