PDA

View Full Version : Use code from Visual Studio 2015 in QT / Input-Output box



Guest3
21st September 2016, 21:13
Hi. I've made a really basic iSpy game in Visual Studio 2015, using the console for input/output. Now that I know more c++ I've moved onto working on QT to display an image of a landscape, and then making a console-like input/output box to actually play the game. The problem I'm having is making this input/output box in the main window.

The questions I have are:
how would I make this console inside of the main window,
and how would I use the code from VS to make the game? Would I simply copy it over into my project and paste it where it should be?
Also, if you have a different direction you think I should take this project, feel free to say so.

I'm super sorry about how vague so much of this is, but if you ask I'll do my best to explain in more detail. Thanks.

d_stranz
22nd September 2016, 17:51
how would I use the code from VS to make the game?

Yep, it's vague all right... What is this "code from VS" - is it native Windows or MFC code? Plain old C++? If it is Windows-specific code, you should (or will have to) port it to the Qt equivalent to make it work. If it is C++, it depends on what it is. Plain old C++ classes or functions (i.e. without dependencies on Windows-specific data structures or types) are perfectly usable in Qt apps. If you use Standard Library containers and algorithms (std::vector<>, etc.), these work just fine and don't need to be ported to the Qt equivalent (QVector<>).

So if you have implemented your game logic in OS-independent C++ code, then you should have a minimal amount of porting.

I am not sure what you mean by a "console" - are you referring to something like an MS DOS terminal window where you would type a command and get printed feedback in response? I would replace that with a QLineEdit (for entering the commands) and a read-only QTextEdit or QListWidget for displaying the responses.

Guest3
22nd September 2016, 22:36
I'm pretty sure it's plain old C++, so that should make things easier.
I'm referring to the cmd-looking window that you input into when running the program.
Thanks for your response so far, it's appreciated.

d_stranz
23rd September 2016, 17:32
I'm referring to the cmd-looking window that you input into when running the program.

Since I've never seen the program, I can only guess at what you mean. A screen shot of what you are trying to port would help.

Lesiok
23rd September 2016, 18:30
I'm referring to the cmd-looking window that you input into when running the program.Maybe this (https://github.com/lxde/qtermwidget) is what You need.