我正在关注本教程:
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]转换为非标量类型。
@nm 不。这是创建主窗口(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;
}