本文整理汇总了C++中QTemporaryFile::isOpen方法的典型用法代码示例。如果您正苦于以下问题:C++ QTemporaryFile::isOpen方法的具体用法?C++ QTemporaryFile::isOpen怎么用?C++ QTemporaryFile::isOpen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTemporaryFile
的用法示例。
在下文中一共展示了QTemporaryFile::isOpen方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fileNameIsEmpty
void tst_QTemporaryFile::fileNameIsEmpty()
{
QString filename;
{
QTemporaryFile file;
QVERIFY(file.fileName().isEmpty());
QVERIFY(file.open());
QVERIFY(!file.fileName().isEmpty());
filename = file.fileName();
QVERIFY(QFile::exists(filename));
file.close();
QVERIFY(!file.isOpen());
QVERIFY(QFile::exists(filename));
QVERIFY(!file.fileName().isEmpty());
}
QVERIFY(!QFile::exists(filename));
}
示例2: addPrepEntry
/// @brief Adds entry to the file.
///
/// Some entries may be ignored because of their namespace. Entries from Wiktionary
/// namespace are ignored for now.
///
/// The contents of the entry can be changed before saving.
///
/// Prep modifies entry content:
/// - <nowiki> sections are converted to HTML entities and the tags are removed.
/// - <noinclude> blocks are removed with their content
/// - HTML comments <!-- --> are removed with their content
/// - <includeonly> tags are removed, but not the contents between them
///
/// @param name
/// Name of entry. Includes the optional namespace.
/// @param contents
/// Entry contents in wiki syntax.
static void addPrepEntry(const QString &name, QString contents)
{
// Skip pages from Wikitonary namespace.
if (name.contains("Wiktionary:")) return;
// Apply errata if it exists.
contents = errata.value(name, contents);
// Remove comments from contents.
contents = StringUtils::removeBlock(QRegExp("<!--"), QRegExp("-->"), contents);
// Remove includeonly tags, but not the content between them.
contents.remove(QRegExp("<includeonly\\s*>"))
.remove(QRegExp("</includeonly\\s*>"));
// Remove __TOC__ magic word, because we handle Table of Contents in
// a separate window.
contents.remove("__TOC__");
// Do not remove <nowiki/> tags. They are used as a separator between wikisyntax
// that cannot be parsed together.
// Substitute special wiki characters in <nowiki> sections with
// html chars and removes the <nowiki> tags.
contents = substituteSpecialCharactersNoWiki(contents);
if (!temporaryFile.isOpen())
temporaryFile.open();
qint64 offset = temporaryFile.pos();
// Save data to the content file.
FileUtils::writeString(temporaryFile, name);
FileUtils::writeString(temporaryFile, contents);
// Add an entry to the link list.
links.push_back(Link(name, offset));
}