Good day to all of you, whoever sees my question. I have a dll, which is written on c++ and some GUI QT project. The dll function sends packets in this cycle when called:
for (int offset = 0; offset < filelen; offset += 4)
{
for (int i = 0; i < 4 ; i++)
{
FPGA_Packet.DATA[i] = (program_data[i + offset];
}
if ( SOCKET_ERROR == ( send(mysocket, (char*)&FPGA_Packet, 8, 0) ))
{
error = WSAGetLastError();
return error;
}
}
The problem is, that i need to increment progressbar every time by offset, when i call "send" function. The question is - how can i establish the connection between GUI and DLL? Must i use slots and signals, or i can solve it with "connect" thread function, or there are simplier or harder options? I need to give the DLL the pointer on form, or somehow use the get/set? I'll appretiate any advices, links, examples and all other help. Thank you.
You have to emit a signal from you function ( or better say a model if we are talking about MVC patter implementation ) and catch it inside your view class. Here is a code snippet for this ( I'm using QML for GUI developing but the idea must be clear anyhow ) :
QObject * const callViewObject = getView()->getSlotsSignalsObject();
bool isSlotSignalConnected = false;
isSlotSignalConnected = QObject::connect( this,
SIGNAL( clearViewSignal() ),
callViewObject,
SLOT( clearViewSlot() ) );
where, getView()->getSlotsSignalsObject() is implemented in the following way :
QObject * const QmlViewBase::getSlotsSignalsObject() const
{
return reinterpret_cast<QObject* const >( m_declarativeView->rootObject() );
}
To declare a signal you have to use the following definition in your class :
signals:
void clearView();
Don't forget that in case your class utilizes signal-slot feature you must put Q_OBJECT
macro inside it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.