0

I'm currently developing on a tool with some existing large C++ code. I'm currently thinking about using a model-view-controller (MVC) design. The model should contain all the C++ code. The view is what the user sees and the controller is basically the glue between the model and the view.

The features that I'm looking for are:

  • Expandable design with MVC
  • Textual User Interface (TUI), terminal and Graphical User Interface (GUI) option
  • The GUI should load some textual files
  • The GUI should use some textual input of the user to run some algorithms and generate some output values
  • The GUI should eventually pop-up, save, display some graph with GNU plot for example.
  • The C++ code works great in Eclipse (libraries, includes, build options)
  • In time new algorithms will be added to the C++ code, this shouldn't become a big problem.

Now I found 3 solutions:

  • QT -> QT Creator nearly demands the usage of an IDE that makes it messy to go to from Eclipse despite the advantages of QT. QT also seems to demand a weird structure around the GUI, so i'm confused about how to make a controller. The eclipse plugin is currently dead, I cannot find it on the FTP of QT and Nokia.
  • GTKmm -> Comes from C and is sometimes a bit hard to understand why some things are required. I believe I can make this work in a MVC design.
  • Java Swing using a shared library (JNI) -> Makes use of Java and C++, which is a bit odd. Using JNI might cost some additional work on the existing C++ code.

I have some experience with Java Swing and nearly no experience with QT and GTKmm.

So what is the best solution for making a GUI when I already have an existing C++ code as an inexperienced UI developer?

Bear
  • 35
  • 2
  • 4
  • 2
    "Qt nearly demands the usage of an IDE" - euh, no? Use an IDE if you want to, but there's nothing that forces you to. If you're comfortable with Eclipse stick with that. (The UI designer stuff is "weird", I never use it myself. Can be done directly in plain Qt C++ with a text editor.) – Mat Mar 15 '13 at 10:26
  • That is why I said 'nearly', I know it is possible to stick with Eclipse. You mean by importing some libraries and use come includes from Qt and then start working in Eclipse or text editor? Thank you for your comment. – Bear Mar 15 '13 at 10:32
  • Qt C++ is C++. There's a couple build-related things that need special attention, but that's it. You can build a GUI with Vim & `qmake` (or Emacs, or Notepad). – Mat Mar 15 '13 at 10:47
  • Ok. As in [link](http://doc.qt.digia.com/4.7/gettingstartedqt.html). Well designing the UI then doesn't give me much trouble, but how do I connect QT with my existing C++ code. Include my headers and .cpp files to the .pro file or should I make a library first of my existing C++ code? – Bear Mar 15 '13 at 11:12
  • You'll automatically (want to) forget all about Eclipse once you started using Qt Creator. Believe me. – Tilman Vogel Mar 15 '13 at 18:35

1 Answers1

3

Of your 3 options, I would definitely go with Qt.

Basically for Qt to be a functional GUI, you need to start QApplication, show() some sort of widget and then start the event loop for the application (QApplication::exec()).

http://qt-project.org/doc/qt-4.8/qapplication.html

http://qt-project.org/doc/qt-4.8/qapplication.html#exec

Qt is extremely flexible and well thought out, and has a strong following. And it has incredible documentation.

To interact with your existing C++ data structures, just construct them as a member variable as one of the main widgets that you have for your GUI. Then when you want to access and display information on it, it is a piece of cake.

http://qt-project.org/doc/qt-4.8/qwidget.html

http://qt-project.org/doc/qt-4.8/qmainwindow.html

Most of the GUI elements in Qt only act as the view, and there isn't any definitive Model and Controller setup. That is left to the developer. If you are displaying a database or a tree or a grid of items there is a model/view flow, but I don't think it applies to your application.

Understanding and using SIGNALS and SLOTS is essential to making an interactive GUI in Qt, and is very painless.

http://qt-project.org/doc/qt-4.8/signalsandslots.html

http://qt-project.org/doc/qt-4.8/qobject.html#details

Reading up on all the different kinds of QWidgets out there, you should be able to find each of the elements you listed in your question.

Here are some you should look at:

http://qt-project.org/doc/qt-4.8/qtextstream.html

http://qt-project.org/doc/qt-4.8/qtextedit.html

http://qt-project.org/doc/qt-4.8/qlineedit.html

http://qt-project.org/doc/qt-4.8/qlabel.html

And of course look through the tutorials and examples that come with Qt.

How to use GNUPlot with Qt

http://lists.trolltech.com/qt-interest/2002-12/thread00068-0.html

Also, as a developer that has used both Qt Creator and Eclipse, I prefer Qt Creator, and porting a project to work in Qt Creator is very straight forward. If you want to change the build chain of Eclipse to use the Qt libraries and QMake, it is possible too.

http://qt-project.org/doc/qt-4.8/qmake-project-files.html

http://qt-project.org/doc/qt-4.8/qmake-project-files.html#declaring-other-libraries

http://therning.org/magnus/archives/1023

I hope that is helpful. Good luck.

phyatt
  • 18,472
  • 5
  • 61
  • 80
  • I really appreciate your comment. It helped me out in my struggle with how to get it working in QT. Thank you. – Bear Mar 16 '13 at 15:05