Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7978383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:28:51+00:00 2026-06-04T09:28:51+00:00

Currently I have some troubles passing a QVector between to threads. At the moment

  • 0

Currently I have some troubles passing a QVector between to threads. At the moment I have a main thread (GUI-Thread) and an worker thread that emits frequently QVector arrays. Directly before emitting the data inside the vector looks good. The receiver is a slot in the main thread but the Data received in by the slot is garbled.

Here are some parts of my code:

Emit in the worker thread:

void Pipeline::process
{
    QVector<float> buffer(w * h * d);

    // filling the vector with RGB-Values

    emit this->pushBuffer(buffer, w, h, d);
}

Connection of signal and slot in the main thread:

QObject::connect(this->_pipeline.data(), SIGNAL(pushBuffer(const QVector<float>, int, int, int)), this->ui->widgetFiltered, SLOT(setBuffer(const QVector<float>,int,int,int)));

Slot in the main thread:

void GLWidget::setBuffer(const QVector<float> buffer, int dataSizeX, int dataSizeY, int dataSizeZ)
{
    // at this point the contents inside 'buffer' is garbled
}

The Thread is started by using QObject’s moveToThread and QVector<float> registered to the meta-system by qRegisterMetaType< QVector<float> >("QVector<float>"); in the main method.

Is it possible that the data gets lost after Pipeline::process returns? I am not sure how the implicit sharing inside QVectorbehaves in this multi-threaded case.

Any help would be appreciated.

Greetings

Wolf

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T09:28:52+00:00Added an answer on June 4, 2026 at 9:28 am

    a) Register metatype QVector. Add this line before app.exec() in your main function:

    qRegisterMetaType<QVector<float> >("QVector<float>");
    

    Without this QueuedConnection won’t work.

    b) explicitly say that your signal and slot connected via Qt::QueuedConnection
    if you do moveToThread after connect, this should fix slot execution in proper thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have some stuff that may be exported into various formats. Currently we have
I have some code that currently checks for minimum and maximum lentgh. I want
I currently have a table structure that looks something like this(some details omitted): ColumnName
I have some troubles with testing in Rails 3. I'm currently upgrading a Rails2
I currently have some action associated with when the user types something in a
I currently have some code which when you press the submit button, a marker
I'm using Zend_Search_Lucene, the PHP port of Java Lucene. I currently have some code
Currently i have some interfaces (stripped down for here): public interface IJobGroup { string
I have some the page elements split into separate visual blocks. I am currently
I currently have a app on the market it saves some data with onRetainNonConfigurationInstance

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.