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

  • Home
  • SEARCH
  • 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 9002491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:34:41+00:00 2026-06-16T00:34:41+00:00

I am using QBuffer in ReadWrite mode. One worker QThread pushes data in the

  • 0

I am using QBuffer in ReadWrite mode. One worker QThread pushes data in the buffer and another QThread reads from it.

Does QBuffer guarantee thread-safety or do I need to derive from QBuffer and add mutex stuff?

  • 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-16T00:34:42+00:00Added an answer on June 16, 2026 at 12:34 am

    To quote Mark Summerfield’s book C++ GUI Programming with Qt 4:

    Qt’s thread-safe classes include QMutex, QMutexLocker, QReadWriteLock,
    QReadLocker, QWriteLocker, QSemaphore, QThreadStorage, and
    QWaitCondition. In addition, parts of the QThread API and several
    other functions are thread-safe, notably QObject::connect(),
    QObject::disconnect(), QCoreApplication::postEvent(), and
    QCoreApplication::removePostedEvents().

    Qt expects that you will use locking mechanisms around most of it’s classes. The docs will say “All functions are thread-safe” if they are, and the individual functions will also specify “is thread-safe”.

    Notes on Qt Classes

    Many Qt classes are reentrant, but they are not
    made thread-safe, because making them thread-safe would incur the
    extra overhead of repeatedly locking and unlocking a QMutex. For
    example, QString is reentrant but not thread-safe. You can safely
    access different instances of QString from multiple threads
    simultaneously, but you can’t safely access the same instance of
    QString from multiple threads simultaneously (unless you protect the
    accesses yourself with a QMutex).

    Some Qt classes and functions are
    thread-safe. These are mainly the thread-related classes (e.g. QMutex)
    and fundamental functions (e.g. QCoreApplication::postEvent()).

    Because QBuffer is a direct subclass of QIODevice I would especially expect it not to be thread-safe, but there are container classes that are thread-safe for read-access, but would require locking for write access:

    Container Classes

    The container classes are implicitly shared, they are reentrant, and
    they are optimized for speed, low memory consumption, and minimal
    inline code expansion, resulting in smaller executables. In addition,
    they are thread-safe in situations where they are used as read-only
    containers by all threads used to access them.

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

Sidebar

Related Questions

Using the http://www.ifans.com/forums/showthread.php?t=132024 post from another question i am allowing the user to enter
Using myObject.performClick() I can simulate click event from the code. Does something like this
Using Android NDK is it possible (from native C-code) to get a list of
Using JQuery,Is there any possible to capture images/scanned documents from digital Camera/Scanner Connected to
Using jQuery, how do I get the value from a textbox and then load
using grep, vim's grep, or another unix shell command, I'd like to find the
Using PHP I am running str_replace many times in a row to switch one
Using MySQL for basic storage of system/user data. I need to store/search messages (adding
Using CMake I want to check if a particular function (cv::getGaborKernel) from OpenCV library
Using Visual C++ 2008. First time, I'm experimenting in crossing over from C# and

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.