1

我有以下内容:

QString themePath(":/themes/");

std::vector<QString> resourcePaths;
resourcePaths.push_back(QString("html/details.html"));

std::vector<QFile> resources;
for (std::vector<QString>::iterator it = resourcePaths.begin(); it != resourcePaths.end(); ++it) {
    QString path = QString("%1%2/%3").arg(themePath, THEME, *it);
    QFile resource(path);
    resources.push_back(resource);
}

给我以下错误: error: 'QFile::QFile(const QFile&)' is private

如果我使用 QList 而不是 std::vector,我会得到同样的错误。

感谢您的关注。

4

1 回答 1

1

问题是您在容器中使用 QFile 值,这些值使用复制构造函数隐式执行项目的复制,该构造函数是 QFile 类的私有成员函数。编译器会告诉你。为了解决这个问题,您可以尝试简单地存储 QFile 指针。

于 2013-11-12T18:07:46.917 回答