0

I am currently working in a project where i have perform some operations in data structure (hash_map/unordered_map) and display the time taken for performing those operations and in the end i have show a summary of all the time taken to perform different operations. I have written my code in GNU C++ in linux and i am able to show the above requirements in the terminal(vi editor) using a Menu Driven Program.

My problem started when my manager told me to use a GUI instead of Menu in the program. How can i integrate the GUI with my existing code in GNU C++. While googling I see they give QT and GTK+ as an option to create GUI in C++ but my problem is i have my code already written in C++ (GNU) and i include some specific headers (#include "hash_map" / #include "unordered_map") in my program.

So what should be my approach. Please help cause i am not being able to move forward in my project..

genpfault
  • 51,148
  • 11
  • 85
  • 139
newars
  • 11
  • 1
  • 2
    have you tried either of those? Using Qt doesn't prevent you from using the `std::` containers at all. – Mat May 25 '11 at 19:31
  • @Mat : but i have a non-standard container which is hash_map that SGI provides to GNU C++.. – newars May 25 '11 at 19:33
  • so? Qt doesn't have anything with that name, there is no reason to have a conflict. – Mat May 25 '11 at 19:33
  • @Mat: while going through some tutorials in QT is have come to see that QT has its own header files which starts with q.. so i believe i may have problem using QT because my program is already written.. will i have a problem?? – newars May 25 '11 at 19:37
  • 2
    just try it. the fact that Qt puts "Q" in front of pretty much anything is _good_ for you. you will not have name clashes unless you have defined classes or headers named the same way as Qt's ones, and even then you can probably use namespaces to get around that. no one can tell if you'll have issues or not without seeing your code, and _you_ won't be able to tell until you've actually tried. Same thing with GTK+. – Mat May 25 '11 at 19:39
  • @Mat.. Thank you for your suggestions. Let me give u an overview of my project code: – newars May 25 '11 at 19:43
  • @Mat: i have to add data (name and number) in a data structure which of hash_map type (SGI hash_map) hash_map. and when i successfully add a new data i must be able to show the time taken to perform that operation. Now how do i do that if i make a button in QT to add a data and run my code having hash_map in background.. I have no idea... – newars May 25 '11 at 19:47
  • read the Qt documentation, or the GTK documentation, to get the basics. try to build a very simple app that does what you want except the "background" part. Once it looks good, read more documentation related to threading. Link your code in once you've got that. BTW: be careful with the licencing, especially ff your code is proprietary. – Mat May 25 '11 at 19:50
  • @Mat: Thanks.. where will i get QT documentation.. please provide me with the link.. Thank you once agn!! – newars May 25 '11 at 19:54
  • type "Qt docs" in google or your favorite search engine. – Mat May 25 '11 at 19:55
  • I like http://www.qtforum.org and http://www.qtcentre.org but they also have excellent help documentation with the SDK if you're using QTCreator you can just select something and hit F1 to get plenty of info on it in a side pane. – AJG85 May 25 '11 at 23:32

1 Answers1

0

Qt is a great option to easily create GUIs with the C++ language

Your general process is going to be

1. Build your data structure operations into a shared or static library.

  • You can use QMake to do this (which should be included when you install QT Creator, the IDE for QT) or by modifying the existing way you build
  • Depending on how you have structured your code this may be a hard or easy task. Hopefully your main is delegating most of the work to other classes. (If it isn't you'll get to be familiar with an activity called "refactoring")

2. Link to the library and call it from your existing menu driven interface

  • If things work correctly, congratulations continue to creating a UI
  • If things don't behave the same, see previous comment about refactoring

3. Create a UI with QT Creator. Link to the library and call from the UI

  • Add functionality until it satisfies the requirements.
  • Do your future peers a favor and look into something called the model-view-controller design pattern and how it applies to UIs. A little organization is going to make your work less likely to be thrown away in the future.

References

ccozad
  • 1,119
  • 8
  • 13