本文整理汇总了C++中QLocalSocket::disconnect方法的典型用法代码示例。如果您正苦于以下问题:C++ QLocalSocket::disconnect方法的具体用法?C++ QLocalSocket::disconnect怎么用?C++ QLocalSocket::disconnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLocalSocket
的用法示例。
在下文中一共展示了QLocalSocket::disconnect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getKeyValue
int QmKeysPrivate::getKeyValue(const struct input_event &query) {
// Try to connect to qmkeyd.
QLocalSocket socket;
socket.connectToServer(SERVER_NAME);
if (!socket.waitForConnected(1000)) {
return -1;
}
// Query for the given key
if (socket.write((char*)&query, sizeof(query)) != sizeof(query)) {
return -1;
}
if (!socket.waitForReadyRead(1000)) {
return -1;
}
struct input_event response;
int ret = 0;
// A loop because we might receive other events as well.
do {
ret = socket.read((char*)&response, sizeof(response));
if (ret == sizeof(response)) {
if (response.type == query.type && response.code == query.code) {
break;
}
}
} while (ret == sizeof(response));
socket.disconnect();
return response.value;
}