简体   繁体   中英

Can I use QBS for creating user defined run configuration files?

I am building a program in QT that is going to need a user definable run configuration file, similar to .vimrc . In short, it will need to define what keypresses are responsible for basic commands in a curses like interface.

I have not quite decided what format to use, but thought that QBS might suit the bill as I am already using it for project management, and it would seem that on the surface that it would be well suited for this sort of thing.

The idea is to have the configuration file sitting in /home/me/.programrc , which is easy enough. I do not know however what interpreters exist for its syntax in Qt or C++, if any, or whether it is practically suited to serve as a run configuration in the first place.

Is this whole idea conceptualized properly, and do adequate tools exist for achieving this goal?

Thanks.

QBS is now deprecated in favor of CMake (along with QMake).

You can add a ".qmake.conf" file in the same dir where you .pro file resides. In this file you can store parameters which you can use in .pro/.pri files.

.qmake.conf

        BUILD_DIR=$$shadowed($$PWD)/build
  BUILD_TESTS_DIR=$$shadowed($$PWD)/unit_tests
      SCRIPTS_DIR=$$PWD/scripts
      TOP_SRC_DIR=$$PWD

project.pro

DESTDIR = $$BUILD_DIR/
INCLUDEPATH += $$TOP_SRC_DIR/

You could add your keypress confiog in the DEFINES parameter, eg for TOP_SRC_DIR:

DEFINES += "TOP_SRC_DIR=\\\"$$TOP_SRC_DIR\\\""

TOP_SRC_DIR is now known in your source code as a define. Of course you will need to rebuild the file(s) which use the define so you may bind the define(s) to centralized "extern" variable(s) which you link to and force re-linking when the parameters change (eg PRE_TARGETDEPS += $BUILD_DIR/myParams.a)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM