简体   繁体   English

Qt应用程序“内部”应用程序

[英]Qt Application “within” application

Qt 4.8.2, windows 7 x64 (But I should be thinking about this as a generic implementation, not OS dependant -if possible-) Qt 4.8.2,Windows 7 x64(但我应该将其视为通用实现,而不是依赖于OS-如果可能的话)

This is a conceptual question and also about implementation. 这是一个概念性问题,也涉及实施。

I have a (Very) simple QApplication. 我有一个(非常)简单的QApplication。 It reads an XML with "button" tags, for each "button", add a new QPushButton to the layout. 它读取带有“按钮”标签的XML,对于每个“按钮”,在布局中添加一个新的QPushButton。 This allows me to dynamically generate a gui based on a config file (The XML). 这使我可以基于配置文件(XML)动态生成GUI。 My issue is taking it to the "next level". 我的问题是将其带入“下一个层次”。

I want to start associating those buttons with other modules (for example: QDialog), which would then do whatever it is they have to do. 我想开始将这些按钮与其他模块(例如QDialog)相关联,然后它们将执行它们必须要做的任何事情。

My final objective is to have an application that "reads a configuration file" (xml) and based on its info, it generates as many buttons as modules were read. 我的最终目标是拥有一个“读取配置文件”(xml)的应用程序,并根据其信息生成与读取模块一样多的按钮。 After that, "connect" the buttons "launch commands" (I don't have a better wording for it right now) which would run as a normal module would... until you close it, then you would return to the menu. 之后,“连接”按钮“启动命令”(我现在没有更好的措辞),它将像普通模块一样运行,直到关闭它,然后返回菜单。

I basically want to have a menu that is dynamically generated (by reading the XML file) and then connects those buttons to execute/start my modules. 我基本上想拥有一个动态生成的菜单(通过读取XML文件),然后将这些按钮连接起来以执行/启动我的模块。 I also want it to be flexible, so if tomorrow I add a new module to my XML and the module into the app folder, I want it to be able to launch it. 我还希望它具有灵活性,因此如果明天我将一个新模块添加到XML中并将该模块添加到app文件夹中,则希望它能够启动它。

My questions are: 我的问题是:

  1. Was I clear enough? 我清楚了吗?

  2. How do games normally go about executing processes? 游戏通常如何执行流程? For example; 例如; A "Menu" from a videogame (in most AAAs) is usually made in Action Script or something similar, and then, when you select "new game" or "load game", etc, it executes certain other Modules (for lack of a better word), particularly the transition between the New Game button and loading the DirectX application and stuff. 视频游戏中的“菜单”(在大多数AAA中)通常是用动作脚本或类似方法制作的,然后,当您选择“新游戏”或“加载游戏”等时,它会执行某些其他模块 (因为缺少更好的字眼),尤其是“新建游戏”按钮与加载DirectX应用程序和内容之间的过渡。

  3. How would one go about developing such projects? 人们将如何开展此类项目? Should I make multiple projects inside a common solution? 我应该在一个通用解决方案中制作多个项目吗?

As you can see, I don't have that much knowledge about software design, so if you think my questions are too basic and you have some book you'd suggest I am willing to read on the subject, I do admit I am more than a bit lost and any sort of advice is welcome. 如您所见,我对软件设计没有太多的了解,因此,如果您认为我的问题太基础了,并且有一些书建议您愿意阅读该主题,那么我承认我有更多知识有点失落,欢迎任何建议。

As always, if I am not clear enough or I can expand on something, do let me know. 和往常一样,如果我不够清楚,或者我不能扩展某些东西,请告诉我。 I appreciate any and all kinds of help on this topic. 我感谢有关此主题的所有帮助。

Also: if anybody thinks I should change the current tags, tell me so. 另外:如果有人认为我应该更改当前标签,请告诉我。 I figured those were the most appropiate. 我认为这些是最合适的。

You probably don't need to visualize this as an "application within an application". 您可能不需要将其可视化为“应用程序中的应用程序”。 When you break it down, what it really is, is an application that can launch processes, and is configured via xml files. 当您分解它时,它实际上是一个可以启动进程并通过xml文件配置的应用程序。

After that, "connect" the buttons to DLLs? 之后,将按钮“连接”到DLL吗? other .exe files? 其他.exe文件? which would run as a normal application. 它将作为普通应用程序运行。

I am not sure what you mean specifically, when you say connecting to DLLs... But all this really needs to do is launch a subprocess from your app. 当您说连接到DLL时,我不确定您的意思是什么。但是,这真的需要做的就是从您的应用程序启动一个子进程。 If I click button A, then it can launch Application A in a QProcess . 如果单击按钮A,则它可以在QProcess中启动应用程序A。 Your app is the parent process and knows when it will stop running. 您的应用是父进程,知道何时停止运行。

If what you mean when you refer to DLLs is that you want to develop other widgets compiled separately, and be able to dynamically load them in from a button click, then I would think it is still not another application. 如果您指的是DLL,是要开发单独编译的其他小部件,并且能够通过单击按钮动态加载它们,那么我认为它仍然不是另一个应用程序。 You only have one QApplication running at a time. 一次只运行一个QApplication。 If you import new modules containing widgets, they can be shown running under the same existing event loop. 如果导入包含小部件的新模块,则可以显示它们在相同的现有事件循环下运行。

How do games normally go about executing processes? 游戏通常如何执行流程? For example; 例如; A "Menu" from a videogame (in most AAAs) is usually made in Action Script or something similar, and then, when you select "new game" or "load game", etc, it executes certain other Modules (for lack of a better word), particularly the transition between the New Game button and loading the DirectX application and stuff. 视频游戏中的“菜单”(在大多数AAA中)通常是用动作脚本或类似方法制作的,然后,当您选择“新游戏”或“加载游戏”等时,它会执行某些其他模块(因为缺少更好的字眼),尤其是“新建游戏”按钮与加载DirectX应用程序和内容之间的过渡。

This is incorrect. 这是不正确的。

"most AAAs" are a single application. “大多数AAA”是单个应用程序。 Whether they use Action Script or any particular scripting language to build their GUI is irrelevant. 他们是否使用动作脚本或任何特定的脚本语言来构建其GUI都是无关紧要的。 The game is usually a single application; 游戏通常是单个应用程序; you're always in the game. 一直在游戏中。 It always has DirectX or OpenGL or whatever running, whether you're in gameplay or sitting at a menu screen. 无论您是玩游戏还是坐在菜单屏幕上,它始终具有DirectX或OpenGL或任何正在运行的功能。 When you start a game, all that happens is that the game runs a series of functions within the application. 当您启动游戏时,所有发生的事情是游戏在应用程序中运行了一系列功能。

They are not necessarily arranged in "modules" or some other construct that the outside world can access or even knows about. 它们不一定按外部世界可以访问甚至知道的“模块”或其他构造进行排列。 They do not usually "load" other code; 他们通常不“加载”其他代码。 it's simply calling other functions in an application. 它只是在应用程序中调用其他函数。

At it's core, it's no different than a command-line application that waits for the user to type some input, then does something with that input. 在它的核心,这也比等待用户输入一些输入一个命令行应用程序不同,那么如何处理该输入的东西。

"most AAA" games cannot do what you're asking. “大多数AAA”游戏无法满足您的要求。 You can't just add something to an XML file and have them load another game within the current one. 您不能只是将一些内容添加到XML文件中,然后让它们加载当前游戏的另一游戏。 They aren't built that way, and that's not their purpose. 他们不是那样建立的,这不是他们的目的。

If you want to have a flexible menu application that launches other games, then each game must be a separate application, and the menu app should be separate from all of them. 如果要具有一个可启动其他游戏的灵活菜单应用程序,则每个游戏必须是一个单独的应用程序,并且菜单应用程序应与所有这些应用程序分开。 At which point, launching a game is just launching a process. 此时,启动游戏只是启动一个过程。 This is how Steam and similar tools work. 这就是Steam和类似工具的工作方式。

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

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