I work on a project that aims to create a GUI for a certain device, with the tlb file being provided by its manufacturer. The default / recommended way to go is WPF, but I have reasons to consider C++ (portability to non-Windows systems and personal experience).
I was able to get the tlb file to work well with VS2019 and C++ (with CLR support). The problem which I have now is how to interface this further with the Qt framework. Is there a way to configure Qt Creator to accept managed CLR classes? Or add Qt to a Visual Studio code that was not set as a "Qt Project" from scratch, and includes CLR support?
Consider the following C++ code (minimum example):
#include "pch.h"
#include <stdio.h>
#include <iostream>
#include <chrono>
#include <thread>
using namespace System;
public ref class Instrument {
public:
TEMEXTLib::TEM3Class ^theScope;
TEMEXTLib::IDef3^ theDef;
Instrument() {
theScope = gcnew TEMEXTLib::TEM3Class();
theDef = theScope->CreateDef3();
std::chrono::seconds timespan(2);
std::this_thread::sleep_for(timespan);
}
void check() {
int x;
int y;
theDef->GetCLA1(x, y);
std::cout << "X value is: " << x << " and Y value is : " << y;
}
};
int main(array<System::String ^> ^args)
{
Instrument ^machine = gcnew Instrument();
machine->check();
return 0;
}
Is there a way to have a Qt Application that would take these X and Y values in display them in QLabels?
I am a total noob when it comes to Qt-CLR/C++ problems, any suggestion that points in the right direction would be very helpful.
Edit: just to be super clear - this is not about using managed classes from a tlb file in CLR/C++, it's about using them in the C++ (original) version of the Qt framework. As far as I am aware, Qt Creator cannot run in the CLR mode, and valid Qt code in VS is no longer valid if CLR support is turned on. Is there a way to use both in the same time: Qt/C++ and tlb/CLR? Ideally a simple way - that does not involve running a dedicated .NET core host within the native code...