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 7571675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:43:47+00:00 2026-05-30T15:43:47+00:00

I am creating an application which displays the market data and uses it in

  • 0

I am creating an application which displays the market data and uses it in some other forms too. I store market data in a map say
std::map<tickerId, StockData>. Let me give one used case of how this map can be used.

  1. network sends a data packet encapsulating the stock Data at time t. updatePrice(tickerId, latestPrice)
  2. update the stock data in the map. Now, multiple threads can access/update the data. So the map has to be locked for thread-safe operations. Here is the first question, do I need to lock the underlying data too for updates?
  3. There are multiple uses of the new stock data, say, there is a price update on IBM, then I need to update the value of IBM in my portfolio. As well as display the new data on a screen. And there can be several other simultaneous uses.updatePosition(tickerId, price) and updateStockScreen(tickerId, price). Also, separting Gui updates from position update is important as GUI is not the main strength of the application.
  4. I am just troubled about how to implement this type of design. I read about Model/View Design in QT to display data but if View thread reads from the same map, it has to be locked. This leads to an slow/inefficient design. Every time view reads from the model, the model needs to be locked. Is this preffered in real-time GUIs?
  5. To summarize, I have stored a lot of different objects as maps. And objects are updated in realtime. I need to update them and then use them at various locations. It would be great if someone can give me a small example on how to implement such designs.

Some references to useful books are appreciated too.

I am new and trying to achieve too much with my little knowledge so forgive me if I have asked stupid/ill-formed questions.

Thanks
Shiv

  • 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-05-30T15:43:48+00:00Added an answer on May 30, 2026 at 3:43 pm

    It sounds conceptually like you want the model on one thread and the view on another, which I looked into at one point.

    If so…and your model is read-only through the view widget then yes, you have to lock. I’d argue that doing so undermines the elegance of the “decoupling” provided by the model/view separation. But it could be made to work.

    However…if your model is read-write through the view it’s not possible to do correctly at all because of the queued nature of the notification slots. Here’s an archive of a mailing list conversation I had on the qt-interest mailing list on the topic:

    http://blog.hostilefork.com/qt-model-view-different-threads/

    “The short version is that I don’t think it’s feasible for a Model to
    be modified on a non-GUI thread…regardless of whether the model’s
    data has been protected with read/write locks. If what I’m gathering
    is correct, then Qt should probably have an assert that a model and
    its view have the same thread affinity (it doesn’t seem to do that now)”

    A subsequent unit test by a KDE developer verified this.

    I feel the best way to work around this is to keep the model and the view on the same thread, and only modify the model in the GUI thread. So if the worker thread wishes to change it then it should use a signal.

    Whether the worker needs to keep their own copy of the data from which the model was created (or if it needs to get notifications to keep that up to date when the user changes the model through the view) depends on your app. If I understand you correctly, it sounds like like you could probably get away with just ferrying the updates through signal/slots and forgetting them on the worker…

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

Sidebar

Related Questions

I am creating an application which displays some messages and its directions in the
I am creating an application which displays map using MKMapView control. I have a
I am creating small django application which holds some few questions (and answers for
When creating a web application that some how displays the display of a unique
I Am creating an iPhone application which displays an UITableView at the start with
I am creating a application which displays 8 thumbnails per page and it can
I'm creating an application which lets you define events with a time frame. I
I'm creating an application which communicates with the device via FT2232H USB/RS232 converter. For
I am creating an application which tracks the users location using GPS, stores the
I am creating an application which involves so many web-service calls. I am using

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.