【发布时间】:2012-08-18 22:50:26
【问题描述】:
我正在学习本教程:
bit.ly/SBMmwp
我在第一行收到以下错误:
错误:请求从“const char [26]”转换为非标量类型“KAuth::Action”
KAuth::Action readAction = "org.kde.auth.example.read";
KAuth::ActionReply reply = readAction.execute();
if (reply.failed())
{
QMessageBox::information(this, "Error", QString("KAuth returned an error code: %1").arg(reply.errorCode()));
}
else
{
QMessageBox::information(this, "Done!", QString("Successfully authenticated!"));
}
错误在第一行:KAuth::Action readAction = "org.kde.auth.example.read";
为什么会这样?这是与滥用 KAuth API 相关的一些错误,还是常见的 C/C++ 错误。我什至不知道如何将 const char[26] 转换为 non-scalar 类型。
@n.m 不,这是创建主窗口 (GUI) 的事件。完整的代码类似于:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <kauth.h>
#include <QMessageBox>
#include <kauthaction.h>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
KAuth::Action readAction = "org.kde.auth.example.read";
KAuth::ActionReply reply = readAction.execute();
if (reply.failed())
{
QMessageBox::information(this, "Error", QString("KAuth returned an error code: %1").arg(reply.errorCode()));
}
else
{
QMessageBox::information(this, "Done!", QString("Successfully authenticated!"));
}
}
MainWindow::~MainWindow()
{
delete ui;
}
【问题讨论】:
-
这是您要编译的整个程序吗?
标签: c++ authentication