0
votes

I have these 2 signals :

void dataSampled(size_t a);
void error(const QString& message);

Elsewhere :

    m_acquisitionThread = new QThread(this);
    m_acquisitionManager = new AcquisitionManager();
    QObject::connect(m_acquisitionManager, &AcquisitionManager::dataSampled,
                     this,                 &Application::onDataSampled); // this Application pointer
    QObject::connect(m_acquisitionManager, &AcquisitionManager::error,
                     this,                 &Application::showError); // this Application pointer
    m_acquisitionManager->moveToThread(m_acquisitionThread);
    m_acquisitionThread->start();

AcquisitionManager is an object moved to a thread, Application lives in the "main" thread.

When I send signals to Application, the slot connected to dataSampled which requires a size_t is not executed, changing size_t by an int (only the signal, the slot can remain size_t) or even removing it fixes the issue. This is really strange, has anyone an idea why the signal is not sent ? In an another application (but single threaded), I tested that size_t are sent from a signal to a slot without a problem (but again the context is different).

void AcquisitionManager::executeDataAcquisition()
{
    emit dataSampled(666); // onDataSampled is never executed (only if I change signal type from size_t to an int or something else)
    emit error("foobar"); // Application::showError is always executed !
1
Have you tried connecting with Qt::QueuedConnection? That should take care of it without having to register it as a meta type.aalimian

1 Answers

0
votes

registering size_t fixed the issue :

 qRegisterMetaType<size_t>("size_t");

But, isn't size_t a primitive type like int ?