本文整理汇总了C++中QVariantHash::take方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariantHash::take方法的具体用法?C++ QVariantHash::take怎么用?C++ QVariantHash::take使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariantHash
的用法示例。
在下文中一共展示了QVariantHash::take方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onSocketReadyRead
void Asterisk::onSocketReadyRead()
{
// qDebug("<ready-read>");
QVariantHash headers;
while (socket.canReadLine()) {
QByteArray line = socket.readLine();
// qDebug() << "Line:" << line;
if (line != "\r\n") {
QStringList header = QString(line.trimmed()).split(':');
headers.insertMulti(header[0], decodeValue(header[1].trimmed()));
} else {
if (headers.contains("Response"))
responses.insert(headers.take("ActionID").toString(), headers);
else if (headers.contains("Event"))
emit eventReceived(headers.take("Event").toString(), headers);
headers.clear();
}
}
// qDebug("</ready-read>");
}
示例2: finishClicked
bool PageAddPrinter::finishClicked()
{
bool ret = false;
QVariantHash args = values();
// Check if it's a printer or a class that we are adding
bool isClass = !args.take(ADDING_PRINTER).toBool();
QString destName = args[KCUPS_PRINTER_NAME].toString();
QString filename = args.take(FILENAME).toString();
KCupsRequest *request = new KCupsRequest;
if (isClass) {
args[KCUPS_PRINTER_IS_ACCEPTING_JOBS] = true;
args[KCUPS_PRINTER_STATE] = IPP_PRINTER_IDLE;
request->addOrModifyClass(destName, args);
} else {
request->addOrModifyPrinter(destName, args, filename);
}
request->waitTillFinished();
if (request->hasError()) {
kDebug() << request->error() << request->errorMsg();
QString message;
if (isClass) {
message = i18nc("@info", "Failed to add class: '%1'", request->errorMsg());
} else {
message = i18nc("@info", "Failed to configure printer: '%1'", request->errorMsg());
}
ui->messageWidget->setText(message);
ui->messageWidget->animatedShow();
} else {
ret = true;
}
request->deleteLater();
return ret;
}
示例3: request
ReturnArguments KCupsConnection::request(ipp_op_e operation,
const char *resource,
const QVariantHash &reqValues,
bool needResponse)
{
ReturnArguments ret;
if (!readyToStart()) {
return ret; // This is not intended to be used in the gui thread
}
ipp_t *response = NULL;
bool needDestName = false;
int group_tag = IPP_TAG_PRINTER;
do {
ipp_t *request;
bool isClass = false;
QString filename;
QVariantHash values = reqValues;
ippDelete(response);
if (values.contains(QLatin1String("printer-is-class"))) {
isClass = values.take(QLatin1String("printer-is-class")).toBool();
}
if (values.contains(QLatin1String("need-dest-name"))) {
needDestName = values.take(QLatin1String("need-dest-name")).toBool();
}
if (values.contains(QLatin1String("group-tag-qt"))) {
group_tag = values.take(QLatin1String("group-tag-qt")).toInt();
}
if (values.contains(QLatin1String("filename"))) {
filename = values.take(QLatin1String("filename")).toString();
}
// Lets create the request
if (values.contains(QLatin1String(KCUPS_PRINTER_NAME))) {
request = ippNewDefaultRequest(values.take(QLatin1String(KCUPS_PRINTER_NAME)).toString(),
isClass,
operation);
} else {
request = ippNewRequest(operation);
}
// send our user name on the request too
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
"requesting-user-name", NULL, cupsUser());
// Add the requested values to the request
requestAddValues(request, values);
// Do the request
// do the request deleting the response
if (filename.isEmpty()) {
response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, resource);
} else {
response = cupsDoFileRequest(CUPS_HTTP_DEFAULT, request, resource, filename.toUtf8());
}
} while (retry(resource));
if (response != NULL && needResponse) {
ret = parseIPPVars(response, group_tag, needDestName);
}
ippDelete(response);
return ret;
}