为共享内存指定关键字有两种方法:
① 通过构造函数QSharedMemory::QSharedMemory ( const QString & key, QObject * parent =0 )为实例对象传入关键字;
例如:
SharedMemory* sharememory;
sharememory = newQSharedMemory("QSharedMemoryExample");
② 通过构造函数QSharedMemory::QSharedMemory (QObject * parent = 0 )构造实例对象,之后调用setKey()函数为该实例对象设置关键字。