简体   繁体   English

我可以使用QBS创建用户定义的运行配置文件吗?

[英]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 . 我正在QT中构建​​一个程序,它将需要一个用户可定义的运行配置文件,类似于.vimrc In short, it will need to define what keypresses are responsible for basic commands in a curses like interface. 简而言之,它将需要在类似curses之类的界面中定义哪些按键负责基本命令。

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. 我还没有决定使用哪种格式,但是我认为QBS可能适合该法案,因为我已经将其用于项目管理,并且从表面上看,它很适合这种事情。

The idea is to have the configuration file sitting in /home/me/.programrc , which is easy enough. 想法是将配置文件放在/home/me/.programrc ,这很容易。 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. 但是,我不知道Qt或C ++中有哪些解释器用于其语法(如果有),或者它实际上是否适合首先用作运行配置。

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). 现在不推荐使用QBS,而推荐使用CMake(以及QMake)。

You can add a ".qmake.conf" file in the same dir where you .pro file resides. 您可以在.pro文件所在的目录中添加“ .qmake.conf”文件。 In this file you can store parameters which you can use in .pro/.pri files. 在此文件中,您可以存储可以在.pro / .pri文件中使用的参数。

.qmake.conf .qmake.conf

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

project.pro 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:

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

TOP_SRC_DIR is now known in your source code as a define. 现在,您的源代码中已将TOP_SRC_DIR称为定义。 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) 当然,您将需要重建使用定义的文件,以便可以将定义绑定到链接到的集中式“外部”变量,并在参数更改时强制重新链接(例如PRE_TARGETDEPS + = $ BUILD_DIR / myParams.a)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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