0

I need to add some huge classes (non-GUI) that use CString, CArray etc. to my Qt project on Windows, but I am not sure how to use MFC outside of Visual Studio, via Qt Creator QMake (with VS 2017 compiler).

What libraries do I need to link for that?

I found some examples for CMake that use built-in CMAKE_MFC_FLAG but not much information about QMake.

Alex P.
  • 3,697
  • 9
  • 45
  • 110
  • If it's just `CString`, simply use ATL classes by adding `"AtlStr.h"`. Use `CAtlArray` instead of `CArray` if possible. To add full MFC support, go to project properties, change "Use of MFC" change to static or shared MFC library. You will have to add `#include "afxwin.h"` before including `windows.h`, I am not sure what problems that may cause with QT – Barmak Shemirani Jan 24 '19 at 19:52
  • @BarmakShemirani I will try ATL, but about "go to project properties, change 'Use of MFC'" — I cannot do this because I need to add MFC (some 3rd-party classes that use MFC stuff) to a Qt Creator/QMake project, not to a VS project. – Alex P. Jan 24 '19 at 19:56
  • `What libraries do I need to link for that?` I believe that MS tools use `#pragma comment(lib, "xxx")` inside the source code, so you probably only need to add include and library paths into the .pro file. However, I'm also agree that writing these classes on your own (kind of `class CString : public QString { ... }` is a cleaner approach. – Matt Jan 25 '19 at 08:31

0 Answers0