Results 1 to 6 of 6

Thread: about the QSharedMemory

  1. #1
    Join Date
    Jul 2010
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default about the QSharedMemory

    Hi,all!
    I got a question about class QSharedMemory.
    If I apply a shared memory using QSharedMemory,can I get its content by Windows API(such as CreateFileMapping)?
    Someone says some changes have to be made to the shared memory key,is it true?
    Can you give me some examples?

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: about the QSharedMemory

    I guess you want to use the key as the name of the file mapping?

    If so, you need to convert the QString into a TCHAR array.
    This link might have useful information:
    http://lists.trolltech.com/qt-intere...ad00134-0.html

  3. The following user says thank you to tbscope for this useful post:

    banban0802 (31st July 2010)

  4. #3
    Join Date
    Jul 2010
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: about the QSharedMemory

    To be exactly,I write a interface by Qt4 for my program,but the program is without Qt.
    I hope this two processes communicate by shared memory,can this make it ?
    thank you !

  5. #4
    Join Date
    May 2010
    Location
    slovakia
    Posts
    47
    Thanks
    10
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Maemo/MeeGo

    Default Re: about the QSharedMemory

    if you use qsharedmemory in your program, they cannot communicate

    docs Code:
    1. Warning: QSharedMemory changes the key in a Qt-specific way. It is therefore currently not possible to use the shared memory of non-Qt applications with QSharedMemory.
    To copy to clipboard, switch view to plain text mode 

    but if you use only QT UI and shared memory with shmemget/set or similar non-QT way, than it's ok.

  6. #5
    Join Date
    Aug 2010
    Posts
    2

    Default Re: about the QSharedMemory

    Does anyone have any idea why they did this name mangling? With QtSharedMemory in Qt Solutions, which is the last version of it I've used, it was pretty easy to reproduce the algorithm for generating the key in other languages. But there must be some good reason for why this shouldn't be done...

  7. #6
    Join Date
    Aug 2010
    Posts
    2

    Default Re: about the QSharedMemory

    Found this myself after some Googling:
    http://qt.gitorious.org/qt/qt/merge_requests/1497

    I guess the short answer is that they need to perform the mangling due to naming restrictions on the underlying platform, and that we will have some new functions in 4.8 to work directly with native keys..

Similar Threads

  1. QSharedMemory and C++ objects
    By MattPhillips in forum Qt Programming
    Replies: 7
    Last Post: 29th November 2010, 07:42
  2. (noob question) write qint64 into qsharedmemory
    By daemonna in forum Qt Programming
    Replies: 1
    Last Post: 28th June 2010, 11:28
  3. new vs QSharedMemory
    By JovianGhost in forum Qt Programming
    Replies: 2
    Last Post: 17th March 2010, 00:34
  4. QSharedMemory won't attach
    By MattPhillips in forum Qt Programming
    Replies: 3
    Last Post: 27th November 2009, 15:45
  5. QSharedMemory in processes from different accounts
    By Ursa in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2009, 09:50

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.