C++ console application to Qt GUI
-
wrote on 7 Apr 2011, 06:50 last edited by
I have a C++ console application which works fine on Windows 7. It takes parameters and calls certain functions based on these parameters. Can I just "plug" in the source code into a Qt GUI application or will I need to recode it?
-
wrote on 7 Apr 2011, 06:52 last edited by
Since interactions between widgets in Qt is driven by signals / slots mechanism, I'm afraid a bit of recoding will be needed.
-
wrote on 7 Apr 2011, 06:52 last edited by
you can use the C++ code, sure. But you have to call it and do somethign with results. There you need to convert the parameters (QString to which ever string impl you used, etc.)
-
wrote on 7 Apr 2011, 08:00 last edited by
Or, you just keep the GUI and backend separate, and communicate with the backend process via QProcess.
You will not need a complete re-code in any way you do it, but you probably will need to wrap your existing code a bit to make it ready to interact with a GUI.
-
wrote on 7 Apr 2011, 09:14 last edited by
Sounds like Andre's idea is easiest but the console application that I've made needs to be extremely fast and I'm wondering if the other ideas would make it slower?
-
wrote on 7 Apr 2011, 09:24 last edited by
Would it be an option to re-factor your original code into two pieces? You might create a library (either static or dynamic) that contains the business end of the code. Then, your command line app can build a simple layer on top of that lib to basically just control the I/O: parse the input parameters, and output results to stdout.
You could then use that same lib in your GUI application.
-
wrote on 7 Apr 2011, 09:28 last edited by
I was thinking that when I did a bit of research but I have no idea how to implement this. I have only just started with programming (I have a php background) but I'm picking it up fairly quickly. Any resources I can read up on to get this sorted? I use visual studio 2010 express if that helps.
3/7