Sophie

Sophie

distrib > Mageia > 6 > armv5tl > media > core-updates > by-pkgid > 768f7d9f703884aa2562bf0a651086df > files > 642

qtbase5-doc-5.9.4-1.1.mga6.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qsharedmemory.cpp -->
  <title>QSharedMemory Class | Qt Core 5.9</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.9</td><td ><a href="qtcore-index.html">Qt Core</a></td><td ><a href="qtcore-module.html">C++ Classes</a></td><td >QSharedMemory</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QSharedMemory Class</h1>
<!-- $$$QSharedMemory-brief -->
<p>The <a href="qsharedmemory.html">QSharedMemory</a> class provides access to a shared memory segment. <a href="#details">More...</a></p>
<!-- @@@QSharedMemory -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QSharedMemory&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += core</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign">  Qt 4.4</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="qobject.html">QObject</a></td></tr></table></div><ul>
<li><a href="qsharedmemory-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h2 id="public-types">Public Types</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qsharedmemory.html#AccessMode-enum">AccessMode</a></b> { ReadOnly, ReadWrite }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qsharedmemory.html#SharedMemoryError-enum">SharedMemoryError</a></b> { NoError, PermissionDenied, InvalidSize, KeyError, ..., UnknownError }</td></tr>
</table></div>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qsharedmemory.html#QSharedMemory">QSharedMemory</a></b>(const QString &amp;<i>key</i>, QObject *<i>parent</i> = Q_NULLPTR)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qsharedmemory.html#QSharedMemory-1">QSharedMemory</a></b>(QObject *<i>parent</i> = Q_NULLPTR)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qsharedmemory.html#dtor.QSharedMemory">~QSharedMemory</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsharedmemory.html#attach">attach</a></b>(AccessMode <i>mode</i> = ReadWrite)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const void *</td><td class="memItemRight bottomAlign"><b><a href="qsharedmemory.html#constData">constData</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsharedmemory.html#create">create</a></b>(int <i>size</i>, AccessMode <i>mode</i> = ReadWrite)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void *</td><td class="memItemRight bottomAlign"><b><a href="qsharedmemory.html#data">data</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const void *</td><td class="memItemRight bottomAlign"><b><a href="qsharedmemory.html#data-1">data</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsharedmemory.html#detach">detach</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> SharedMemoryError </td><td class="memItemRight bottomAlign"><b><a href="qsharedmemory.html#error">error</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qsharedmemory.html#errorString">errorString</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsharedmemory.html#isAttached">isAttached</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qsharedmemory.html#key">key</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsharedmemory.html#lock">lock</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qsharedmemory.html#nativeKey">nativeKey</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsharedmemory.html#setKey">setKey</a></b>(const QString &amp;<i>key</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsharedmemory.html#setNativeKey">setNativeKey</a></b>(const QString &amp;<i>key</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qsharedmemory.html#size">size</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsharedmemory.html#unlock">unlock</a></b>()</td></tr>
</table></div>
<ul>
<li class="fn">32 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">1 property inherited from <a href="qobject.html#properties">QObject</a></li>
<li class="fn">1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
<li class="fn">2 signals inherited from <a href="qobject.html#signals">QObject</a></li>
<li class="fn">11 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
<li class="fn">9 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<a name="details"></a>
<!-- $$$QSharedMemory-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qsharedmemory.html">QSharedMemory</a> class provides access to a shared memory segment.</p>
<p><a href="qsharedmemory.html">QSharedMemory</a> provides access to a shared memory segment by multiple threads and processes. It also provides a way for a single thread or process to lock the memory for exclusive access.</p>
<p>When using this class, be aware of the following platform differences:</p>
<ul>
<li>Windows: <a href="qsharedmemory.html">QSharedMemory</a> does not &quot;own&quot; the shared memory segment. When all threads or processes that have an instance of <a href="qsharedmemory.html">QSharedMemory</a> attached to a particular shared memory segment have either destroyed their instance of <a href="qsharedmemory.html">QSharedMemory</a> or exited, the Windows kernel releases the shared memory segment automatically.</li>
<li>Unix: <a href="qsharedmemory.html">QSharedMemory</a> &quot;owns&quot; the shared memory segment. When the last thread or process that has an instance of <a href="qsharedmemory.html">QSharedMemory</a> attached to a particular shared memory segment detaches from the segment by destroying its instance of <a href="qsharedmemory.html">QSharedMemory</a>, the Unix kernel release the shared memory segment. But if that last thread or process crashes without running the <a href="qsharedmemory.html">QSharedMemory</a> destructor, the shared memory segment survives the crash.</li>
<li>HP-UX: Only one attach to a shared memory segment is allowed per process. This means that <a href="qsharedmemory.html">QSharedMemory</a> should not be used across multiple threads in the same process in HP-UX.</li>
</ul>
<p>Remember to lock the shared memory with <a href="qsharedmemory.html#lock">lock</a>() before reading from or writing to the shared memory, and remember to release the lock with <a href="qsharedmemory.html#unlock">unlock</a>() after you are done.</p>
<p><a href="qsharedmemory.html">QSharedMemory</a> automatically destroys the shared memory segment when the last instance of <a href="qsharedmemory.html">QSharedMemory</a> is detached from the segment, and no references to the segment remain.</p>
<p><b>Warning:</b> <a href="qsharedmemory.html">QSharedMemory</a> 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 <a href="qsharedmemory.html#QSharedMemory">QSharedMemory</a>() and then setting a native key with <a href="qsharedmemory.html#setNativeKey">setNativeKey</a>(). When using native keys, shared memory is not protected against multiple accesses on it (for example, unable to <a href="qsharedmemory.html#lock">lock</a>()) and a user-defined mechanism should be used to achieve such protection.</p>
</div>
<!-- @@@QSharedMemory -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$AccessMode$$$ReadOnly$$$ReadWrite -->
<h3 class="fn" id="AccessMode-enum"><a name="AccessMode-enum"></a>enum QSharedMemory::<span class="name">AccessMode</span></h3>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QSharedMemory::ReadOnly</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign">The shared memory segment is read-only. Writing to the shared memory segment is not allowed. An attempt to write to a shared memory segment created with ReadOnly causes the program to abort.</td></tr>
<tr><td class="topAlign"><code>QSharedMemory::ReadWrite</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">Reading and writing the shared memory segment are both allowed.</td></tr>
</table></div>
<!-- @@@AccessMode -->
<!-- $$$SharedMemoryError$$$NoError$$$PermissionDenied$$$InvalidSize$$$KeyError$$$AlreadyExists$$$NotFound$$$LockError$$$OutOfResources$$$UnknownError -->
<h3 class="fn" id="SharedMemoryError-enum"><a name="SharedMemoryError-enum"></a>enum QSharedMemory::<span class="name">SharedMemoryError</span></h3>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QSharedMemory::NoError</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign">No error occurred.</td></tr>
<tr><td class="topAlign"><code>QSharedMemory::PermissionDenied</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">The operation failed because the caller didn't have the required permissions.</td></tr>
<tr><td class="topAlign"><code>QSharedMemory::InvalidSize</code></td><td class="topAlign tblval"><code>2</code></td><td class="topAlign">A create operation failed because the requested size was invalid.</td></tr>
<tr><td class="topAlign"><code>QSharedMemory::KeyError</code></td><td class="topAlign tblval"><code>3</code></td><td class="topAlign">The operation failed because of an invalid key.</td></tr>
<tr><td class="topAlign"><code>QSharedMemory::AlreadyExists</code></td><td class="topAlign tblval"><code>4</code></td><td class="topAlign">A <a href="qsharedmemory.html#create">create</a>() operation failed because a shared memory segment with the specified key already existed.</td></tr>
<tr><td class="topAlign"><code>QSharedMemory::NotFound</code></td><td class="topAlign tblval"><code>5</code></td><td class="topAlign">An <a href="qsharedmemory.html#attach">attach</a>() failed because a shared memory segment with the specified key could not be found.</td></tr>
<tr><td class="topAlign"><code>QSharedMemory::LockError</code></td><td class="topAlign tblval"><code>6</code></td><td class="topAlign">The attempt to <a href="qsharedmemory.html#lock">lock</a>() the shared memory segment failed because <a href="qsharedmemory.html#create">create</a>() or <a href="qsharedmemory.html#attach">attach</a>() failed and returned false, or because a system error occurred in <a href="qsystemsemaphore.html#acquire">QSystemSemaphore::acquire</a>().</td></tr>
<tr><td class="topAlign"><code>QSharedMemory::OutOfResources</code></td><td class="topAlign tblval"><code>7</code></td><td class="topAlign">A <a href="qsharedmemory.html#create">create</a>() operation failed because there was not enough memory available to fill the request.</td></tr>
<tr><td class="topAlign"><code>QSharedMemory::UnknownError</code></td><td class="topAlign tblval"><code>8</code></td><td class="topAlign">Something else happened and it was bad.</td></tr>
</table></div>
<!-- @@@SharedMemoryError -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QSharedMemory[overload1]$$$QSharedMemoryconstQString&QObject* -->
<h3 class="fn" id="QSharedMemory"><a name="QSharedMemory"></a>QSharedMemory::<span class="name">QSharedMemory</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>key</i>, <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>parent</i> = Q_NULLPTR)</h3>
<p>Constructs a shared memory object with the given <i>parent</i> and with its key set to <i>key</i>. Because its key is set, its <a href="qsharedmemory.html#create">create</a>() and <a href="qsharedmemory.html#attach">attach</a>() functions can be called.</p>
<p><b>See also </b><a href="qsharedmemory.html#setKey">setKey</a>(), <a href="qsharedmemory.html#create">create</a>(), and <a href="qsharedmemory.html#attach">attach</a>().</p>
<!-- @@@QSharedMemory -->
<!-- $$$QSharedMemory$$$QSharedMemoryQObject* -->
<h3 class="fn" id="QSharedMemory-1"><a name="QSharedMemory-1"></a>QSharedMemory::<span class="name">QSharedMemory</span>(<span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>parent</i> = Q_NULLPTR)</h3>
<p>This function overloads <a href="qsharedmemory.html#QSharedMemory">QSharedMemory</a>().</p>
<p>Constructs a shared memory object with the given <i>parent</i>. The shared memory object's key is not set by the constructor, so the shared memory object does not have an underlying shared memory segment attached. The key must be set with <a href="qsharedmemory.html#setKey">setKey</a>() or <a href="qsharedmemory.html#setNativeKey">setNativeKey</a>() before <a href="qsharedmemory.html#create">create</a>() or <a href="qsharedmemory.html#attach">attach</a>() can be used.</p>
<p><b>See also </b><a href="qsharedmemory.html#setKey">setKey</a>().</p>
<!-- @@@QSharedMemory -->
<!-- $$$~QSharedMemory[overload1]$$$~QSharedMemory -->
<h3 class="fn" id="dtor.QSharedMemory"><a name="dtor.QSharedMemory"></a>QSharedMemory::<span class="name">~QSharedMemory</span>()</h3>
<p>The destructor clears the key, which forces the shared memory object to <a href="qsharedmemory.html#detach">detach</a> from its underlying shared memory segment. If this shared memory object is the last one connected to the shared memory segment, the <a href="qsharedmemory.html#detach">detach</a>() operation destroys the shared memory segment.</p>
<p><b>See also </b><a href="qsharedmemory.html#detach">detach</a>() and <a href="qsharedmemory.html#isAttached">isAttached</a>().</p>
<!-- @@@~QSharedMemory -->
<!-- $$$attach[overload1]$$$attachAccessMode -->
<h3 class="fn" id="attach"><a name="attach"></a><span class="type">bool</span> QSharedMemory::<span class="name">attach</span>(<span class="type"><a href="qsharedmemory.html#AccessMode-enum">AccessMode</a></span> <i>mode</i> = ReadWrite)</h3>
<p>Attempts to attach the process to the shared memory segment identified by the key that was passed to the constructor or to a call to <a href="qsharedmemory.html#setKey">setKey</a>() or <a href="qsharedmemory.html#setNativeKey">setNativeKey</a>(). The access <i>mode</i> is <a href="qsharedmemory.html#AccessMode-enum">ReadWrite</a> by default. It can also be <a href="qsharedmemory.html#AccessMode-enum">ReadOnly</a>. Returns <code>true</code> if the attach operation is successful. If false is returned, call <a href="qsharedmemory.html#error">error</a>() to determine which error occurred. After attaching the shared memory segment, a pointer to the shared memory can be obtained by calling <a href="qsharedmemory.html#data">data</a>().</p>
<p><b>See also </b><a href="qsharedmemory.html#isAttached">isAttached</a>(), <a href="qsharedmemory.html#detach">detach</a>(), and <a href="qsharedmemory.html#create">create</a>().</p>
<!-- @@@attach -->
<!-- $$$constData[overload1]$$$constData -->
<h3 class="fn" id="constData"><a name="constData"></a>const <span class="type">void</span> *QSharedMemory::<span class="name">constData</span>() const</h3>
<p>Returns a const pointer to the contents of the shared memory segment, if one is attached. Otherwise it returns null. Remember to lock the shared memory with <a href="qsharedmemory.html#lock">lock</a>() before reading from or writing to the shared memory, and remember to release the lock with <a href="qsharedmemory.html#unlock">unlock</a>() after you are done.</p>
<p><b>See also </b><a href="qsharedmemory.html#attach">attach</a>() and <a href="qsharedmemory.html#create">create</a>().</p>
<!-- @@@constData -->
<!-- $$$create[overload1]$$$createintAccessMode -->
<h3 class="fn" id="create"><a name="create"></a><span class="type">bool</span> QSharedMemory::<span class="name">create</span>(<span class="type">int</span> <i>size</i>, <span class="type"><a href="qsharedmemory.html#AccessMode-enum">AccessMode</a></span> <i>mode</i> = ReadWrite)</h3>
<p>Creates a shared memory segment of <i>size</i> bytes with the key passed to the constructor, set with <a href="qsharedmemory.html#setKey">setKey</a>() or set with <a href="qsharedmemory.html#setNativeKey">setNativeKey</a>(), then attaches to the new shared memory segment with the given access <i>mode</i> and returns <code>true</code>. If a shared memory segment identified by the key already exists, the attach operation is not performed and <code>false</code> is returned. When the return value is <code>false</code>, call <a href="qsharedmemory.html#error">error</a>() to determine which error occurred.</p>
<p><b>See also </b><a href="qsharedmemory.html#error">error</a>().</p>
<!-- @@@create -->
<!-- $$$data[overload1]$$$data -->
<h3 class="fn" id="data"><a name="data"></a><span class="type">void</span> *QSharedMemory::<span class="name">data</span>()</h3>
<p>Returns a pointer to the contents of the shared memory segment, if one is attached. Otherwise it returns null. Remember to lock the shared memory with <a href="qsharedmemory.html#lock">lock</a>() before reading from or writing to the shared memory, and remember to release the lock with <a href="qsharedmemory.html#unlock">unlock</a>() after you are done.</p>
<p><b>See also </b><a href="qsharedmemory.html#attach">attach</a>().</p>
<!-- @@@data -->
<!-- $$$data$$$data -->
<h3 class="fn" id="data-1"><a name="data-1"></a>const <span class="type">void</span> *QSharedMemory::<span class="name">data</span>() const</h3>
<p>This function overloads <a href="qsharedmemory.html#data">data</a>().</p>
<!-- @@@data -->
<!-- $$$detach[overload1]$$$detach -->
<h3 class="fn" id="detach"><a name="detach"></a><span class="type">bool</span> QSharedMemory::<span class="name">detach</span>()</h3>
<p>Detaches the process from the shared memory segment. If this was the last process attached to the shared memory segment, then the shared memory segment is released by the system, i.e&#x2e;, the contents are destroyed. The function returns <code>true</code> if it detaches the shared memory segment. If it returns <code>false</code>, it usually means the segment either isn't attached, or it is locked by another process.</p>
<p><b>See also </b><a href="qsharedmemory.html#attach">attach</a>() and <a href="qsharedmemory.html#isAttached">isAttached</a>().</p>
<!-- @@@detach -->
<!-- $$$error[overload1]$$$error -->
<h3 class="fn" id="error"><a name="error"></a><span class="type"><a href="qsharedmemory.html#SharedMemoryError-enum">SharedMemoryError</a></span> QSharedMemory::<span class="name">error</span>() const</h3>
<p>Returns a value indicating whether an error occurred, and, if so, which error it was.</p>
<p><b>See also </b><a href="qsharedmemory.html#errorString">errorString</a>().</p>
<!-- @@@error -->
<!-- $$$errorString[overload1]$$$errorString -->
<h3 class="fn" id="errorString"><a name="errorString"></a><span class="type"><a href="qstring.html">QString</a></span> QSharedMemory::<span class="name">errorString</span>() const</h3>
<p>Returns a text description of the last error that occurred. If <a href="qsharedmemory.html#error">error</a>() returns an <a href="qsharedmemory.html#SharedMemoryError-enum">error value</a>, call this function to get a text string that describes the error.</p>
<p><b>See also </b><a href="qsharedmemory.html#error">error</a>().</p>
<!-- @@@errorString -->
<!-- $$$isAttached[overload1]$$$isAttached -->
<h3 class="fn" id="isAttached"><a name="isAttached"></a><span class="type">bool</span> QSharedMemory::<span class="name">isAttached</span>() const</h3>
<p>Returns <code>true</code> if this process is attached to the shared memory segment.</p>
<p><b>See also </b><a href="qsharedmemory.html#attach">attach</a>() and <a href="qsharedmemory.html#detach">detach</a>().</p>
<!-- @@@isAttached -->
<!-- $$$key[overload1]$$$key -->
<h3 class="fn" id="key"><a name="key"></a><span class="type"><a href="qstring.html">QString</a></span> QSharedMemory::<span class="name">key</span>() const</h3>
<p>Returns the key assigned with <a href="qsharedmemory.html#setKey">setKey</a>() to this shared memory, or a null key if no key has been assigned, or if the segment is using a <a href="qsharedmemory.html#nativeKey">nativeKey</a>(). The key is the identifier used by Qt applications to identify the shared memory segment.</p>
<p>You can find the native, platform specific, key used by the operating system by calling <a href="qsharedmemory.html#nativeKey">nativeKey</a>().</p>
<p><b>See also </b><a href="qsharedmemory.html#setKey">setKey</a>() and <a href="qsharedmemory.html#setNativeKey">setNativeKey</a>().</p>
<!-- @@@key -->
<!-- $$$lock[overload1]$$$lock -->
<h3 class="fn" id="lock"><a name="lock"></a><span class="type">bool</span> QSharedMemory::<span class="name">lock</span>()</h3>
<p>This is a semaphore that locks the shared memory segment for access by this process and returns <code>true</code>. If another process has locked the segment, this function blocks until the lock is released. Then it acquires the lock and returns <code>true</code>. If this function returns <code>false</code>, it means that you have ignored a false return from <a href="qsharedmemory.html#create">create</a>() or <a href="qsharedmemory.html#attach">attach</a>(), that you have set the key with <a href="qsharedmemory.html#setNativeKey">setNativeKey</a>() or that <a href="qsystemsemaphore.html#acquire">QSystemSemaphore::acquire</a>() failed due to an unknown system error.</p>
<p><b>See also </b><a href="qsharedmemory.html#unlock">unlock</a>(), <a href="qsharedmemory.html#data">data</a>(), and <a href="qsystemsemaphore.html#acquire">QSystemSemaphore::acquire</a>().</p>
<!-- @@@lock -->
<!-- $$$nativeKey[overload1]$$$nativeKey -->
<h3 class="fn" id="nativeKey"><a name="nativeKey"></a><span class="type"><a href="qstring.html">QString</a></span> QSharedMemory::<span class="name">nativeKey</span>() const</h3>
<p>Returns the native, platform specific, key for this shared memory object. The native key is the identifier used by the operating system to identify the shared memory segment.</p>
<p>You can use the native key to access shared memory segments that have not been created by Qt, or to grant shared memory access to non-Qt applications.</p>
<p>This function was introduced in  Qt 4.8.</p>
<p><b>See also </b><a href="qsharedmemory.html#setKey">setKey</a>() and <a href="qsharedmemory.html#setNativeKey">setNativeKey</a>().</p>
<!-- @@@nativeKey -->
<!-- $$$setKey[overload1]$$$setKeyconstQString& -->
<h3 class="fn" id="setKey"><a name="setKey"></a><span class="type">void</span> QSharedMemory::<span class="name">setKey</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>key</i>)</h3>
<p>Sets the platform independent <i>key</i> for this shared memory object. If <i>key</i> is the same as the current key, the function returns without doing anything.</p>
<p>You can call <a href="qsharedmemory.html#key">key</a>() to retrieve the platform independent key. Internally, <a href="qsharedmemory.html">QSharedMemory</a> converts this key into a platform specific key. If you instead call <a href="qsharedmemory.html#nativeKey">nativeKey</a>(), you will get the platform specific, converted key.</p>
<p>If the shared memory object is attached to an underlying shared memory segment, it will <a href="qsharedmemory.html#detach">detach</a> from it before setting the new key. This function does not do an <a href="qsharedmemory.html#attach">attach</a>().</p>
<p><b>See also </b><a href="qsharedmemory.html#key">key</a>(), <a href="qsharedmemory.html#nativeKey">nativeKey</a>(), and <a href="qsharedmemory.html#isAttached">isAttached</a>().</p>
<!-- @@@setKey -->
<!-- $$$setNativeKey[overload1]$$$setNativeKeyconstQString& -->
<h3 class="fn" id="setNativeKey"><a name="setNativeKey"></a><span class="type">void</span> QSharedMemory::<span class="name">setNativeKey</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>key</i>)</h3>
<p>Sets the native, platform specific, <i>key</i> for this shared memory object. If <i>key</i> is the same as the current native key, the function returns without doing anything. If all you want is to assign a key to a segment, you should call <a href="qsharedmemory.html#setKey">setKey</a>() instead.</p>
<p>You can call <a href="qsharedmemory.html#nativeKey">nativeKey</a>() to retrieve the native key. If a native key has been assigned, calling <a href="qsharedmemory.html#key">key</a>() will return a null string.</p>
<p>If the shared memory object is attached to an underlying shared memory segment, it will <a href="qsharedmemory.html#detach">detach</a> from it before setting the new key. This function does not do an <a href="qsharedmemory.html#attach">attach</a>().</p>
<p>The application will not be portable if you set a native key.</p>
<p>This function was introduced in  Qt 4.8.</p>
<p><b>See also </b><a href="qsharedmemory.html#nativeKey">nativeKey</a>(), <a href="qsharedmemory.html#key">key</a>(), and <a href="qsharedmemory.html#isAttached">isAttached</a>().</p>
<!-- @@@setNativeKey -->
<!-- $$$size[overload1]$$$size -->
<h3 class="fn" id="size"><a name="size"></a><span class="type">int</span> QSharedMemory::<span class="name">size</span>() const</h3>
<p>Returns the size of the attached shared memory segment. If no shared memory segment is attached, 0 is returned.</p>
<p><b>Note: </b>The size of the segment may be larger than the requested size that was passed to <a href="qsharedmemory.html#create">create</a>().</p><p><b>See also </b><a href="qsharedmemory.html#create">create</a>() and <a href="qsharedmemory.html#attach">attach</a>().</p>
<!-- @@@size -->
<!-- $$$unlock[overload1]$$$unlock -->
<h3 class="fn" id="unlock"><a name="unlock"></a><span class="type">bool</span> QSharedMemory::<span class="name">unlock</span>()</h3>
<p>Releases the lock on the shared memory segment and returns <code>true</code>, if the lock is currently held by this process. If the segment is not locked, or if the lock is held by another process, nothing happens and false is returned.</p>
<p><b>See also </b><a href="qsharedmemory.html#lock">lock</a>().</p>
<!-- @@@unlock -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>