Answer the question
In order to leave comments, you need to log in
How to connect one external library using QLibrary and work with two fixtures independently?
Hello everyone)
I created a library that has the following function:
float getFloat(){
result_float = (float)i++; //для теста, потом здесь будут данные, которые считываются с прибора
return result_float;
}
class ConnectComDevice
{
private:
float result;
public:
void getFloat()
{
QLibrary lib ( LIB_NAME );
if( !lib.load() ) {
qDebug() << "Loading failed!";
}
typedef float ( *outputFloat )();
outputFloat outputFloatd;
for (int i=0; i<5; i++)
{
outputFloatd = ( outputFloat ) lib.resolve( "getFloat" );
if( outputFloatd ) {
qDebug() << outputFloatd();
}
}
}
};
ConnectComDevice connectDevice();
connectDevice.getFloat();
ConnectComDevice connectDevice1();
connectDevice1.getFloat();
Answer the question
In order to leave comments, you need to log in
Declare a class inside the library, include the library, create two objects of your class in the program, and use them.
Now you are trying to include the library twice, it does not make sense. Well, then, QLibrary is also optional, just write the library file and header in the pro file: doc.qt.io/qtcreator/creator-project-qmake-librarie...
Your class method pulls a function that uses a global variable. In order for the value of a variable to correspond to an instance of a class, it must be a member of it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question