Results 1 to 2 of 2

Thread: Can I create multiple data-structures for single QSharedMemory

  1. #1
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    248
    Thanks
    91
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Can I create multiple data-structures for single QSharedMemory

    I need to share multiple data-structures across from my QSharedMemory. I tried "Shared Memory" example, which loads a image from file & from shared memory.
    I need to share multiple structures across QSharedMemory for non-Qt application. If not, is it possible to avoid reading a all the sharedmemory chunk every time when I poll for a change ? Is there any example available depicting this scenario ? Kindly help me. Thank you.

  2. The following user says thank you to rawfool for this useful post:


  3. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Can I create multiple data-structures for single QSharedMemory

    I need to share multiple data-structures across from my QSharedMemory. I tried "Shared Memory" example, which loads a image from file & from shared memory.
    I need to share multiple structures across QSharedMemory for non-Qt application.
    QSharedMemory is just a chunk of memory, one can store multiple data structures in it.

    If not, is it possible to avoid reading a all the sharedmemory chunk every time when I poll for a change ?
    Yes it is always upto programmer to read only the required part of memory, but note that one can get the only one handle to the memory.

    I hope you have read this warning about using QSharedMemory between Qt and non-Qt Application, pay attention to the bold text.
    Quote Originally Posted by Qt Docs Warning
    QSharedMemory changes the key in a Qt-specific way, unless otherwise specified. Interoperation with non-Qt applications is achieved by first creating a default shared memory with QSharedMemory() and then setting a native key with setNativeKey(). When using native keys, shared memory is not protected against multiple accesses on it (e.g. unable to lock()) and a user-defined mechanism should be used to achieve a such protection.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  4. The following 2 users say thank you to Santosh Reddy for this useful post:

    rawfool (8th May 2013)

Similar Threads

  1. Create new QsharedMemory after crash
    By dashesy in forum Qt Programming
    Replies: 1
    Last Post: 30th June 2012, 08:01
  2. Data structures with qt4
    By NewLegend in forum Qt Programming
    Replies: 5
    Last Post: 25th July 2010, 22:57
  3. APIs and Data structures
    By crazymoonboy in forum Qt Programming
    Replies: 0
    Last Post: 30th September 2008, 08:56
  4. How to create filmstrip - multiple images in a single file
    By jessiemmichael in forum Qt Programming
    Replies: 1
    Last Post: 13th June 2008, 09:30
  5. Replies: 2
    Last Post: 17th April 2006, 22:30

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.