I have already written a C++ program and I would like to write a GUI for it. I realize Qt is a wonderful tool, however, Qt has it's own classes, which make me quite confused. eg: instead of String, Qt has a class named QString..
I am wondering if I can mix C++ code and Qt code in C++?
Yes you can intermix Qt and STL very easily.
The GUI takes QString
s but will silently create these form std::string
or char*
, QStrings
returned from Qt can be converted with toStdString()
or toAscii()
.
Qt includes a set of collection classes but you don't have to use them.
Qt does a good job of looking like modern C++, there are a few 'extras' to handle the signal and slot event mechanism but these are more a complication to the build environment than to the code.
edit:thanks bill
I wont recommend mixing std c++ code and Qt code together.
Let's say, your c++ code is the logic then the Qt code , should be just for GUI. Using a MVC/MVP patterns or likewise, separate your logic and UI.
Thus,it would be easier in the future to be able to run your code with/without using a UI.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With