问题描述
我是新来的。我是Qt的初学者,但我是一个中级程序员在c ++。我以前在C ++和STL中编写了一个程序(没有代码是平台相关的,整个程序被分成十个.cpp / .h文件)。现在如果我在qt开发A Gui,我可以链接到我的旧程序,还是应该重写一切?
例如我使用fstream使用文件IO。但在Qt我看到有QFile所以是可能链接它。这个程序相当冗长。所以这将是很难重写一切。
Gui不是强制性的,但我认为这将是对演示文稿是好的。它是我的项目,所以请回复一下。请给我一些例子或网站,如果可能的话。
谢谢提前... Manish
I am new here. I am a beginner in Qt but i am an intermediate level programmer in c++. I had written a program previously in C++ and STL(No code is platform dependent and whole program is broken into around ten .cpp/.h files). Now if I develop A Gui in qt,can I link it to my old program or should I rewrite everything?For instance I use file IO using fstream. But in Qt I see there is QFile so is it possible to link it. The program is pretty lengthy. So it will be very hard to rewrite everything.Gui is not mandatory for me but I thought it would be good for presentation.It is for my Project so please reply soon.Please give me some examples or sites to refer to if possible.Thank you in Advance... Manish
推荐答案
您可以为您的程序编写Qt GUI:
You can write a Qt GUI for your program:
一个选项是使用GUI创建一个单独的程序,使用 QProcess
作为子进程启动程序。 GUI程序将发送命令行参数,您可以与它进行通信。
One option is to create a separate program with GUI that starts your program as a subprocess, using QProcess
. The GUI program will send command line parameters and you can communicate with it.
另一个选项是重写程序的主程序,使其成为另一个函数。您可以让您的GUI程序调用该函数。
Another option is to rewrite the main of your program so that it is another function. You can get your GUI program to call the function.
不需要使用 QFile
Qt,除非你想重写你的程序的一部分或使用Qt的功能。
There is no need to use QFile
or other parts of Qt unless you want to rewrite that part of your program or use a feature of Qt.
这篇关于是否可能有现有的C ++代码与Qt一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!