本文整理汇总了C++中QDesignerFormWindowInterface::setContents方法的典型用法代码示例。如果您正苦于以下问题:C++ QDesignerFormWindowInterface::setContents方法的具体用法?C++ QDesignerFormWindowInterface::setContents怎么用?C++ QDesignerFormWindowInterface::setContents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDesignerFormWindowInterface
的用法示例。
在下文中一共展示了QDesignerFormWindowInterface::setContents方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: open
bool FormWindowEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
{
if (Designer::Constants::Internal::debug)
qDebug() << "FormWindowEditor::open" << fileName;
auto document = qobject_cast<FormWindowFile *>(textDocument());
QDesignerFormWindowInterface *form = document->formWindow();
QTC_ASSERT(form, return false);
if (fileName.isEmpty())
return true;
const QFileInfo fi(fileName);
const QString absfileName = fi.absoluteFilePath();
QString contents;
if (document->read(absfileName, &contents, errorString) != Utils::TextFileFormat::ReadSuccess)
return false;
form->setFileName(absfileName);
const QByteArray contentsBA = contents.toUtf8();
QBuffer str;
str.setData(contentsBA);
str.open(QIODevice::ReadOnly);
if (!form->setContents(&str, errorString))
return false;
form->setDirty(fileName != realFileName);
document->syncXmlFromFormWindow();
document->setFilePath(absfileName);
document->setShouldAutoSave(false);
document->resourceHandler()->updateResources(true);
return true;
}
示例2: open
bool FormWindowEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
{
if (Designer::Constants::Internal::debug)
qDebug() << "FormWindowEditor::open" << fileName;
QDesignerFormWindowInterface *form = d->m_file.formWindow();
QTC_ASSERT(form, return false);
if (fileName.isEmpty()) {
setDisplayName(tr("untitled"));
return true;
}
const QFileInfo fi(fileName);
const QString absfileName = fi.absoluteFilePath();
QString contents;
if (d->m_file.read(absfileName, &contents, errorString) != Utils::TextFileFormat::ReadSuccess)
return false;
form->setFileName(absfileName);
#if QT_VERSION >= 0x050000
const QByteArray contentsBA = contents.toUtf8();
QBuffer str;
str.setData(contentsBA);
str.open(QIODevice::ReadOnly);
if (!form->setContents(&str, errorString))
return false;
#else
form->setContents(contents);
if (!form->mainContainer())
return false;
#endif
form->setDirty(fileName != realFileName);
syncXmlEditor(contents);
setDisplayName(fi.fileName());
d->m_file.setFileName(absfileName);
d->m_file.setShouldAutoSave(false);
if (Internal::ResourceHandler *rh = form->findChild<Designer::Internal::ResourceHandler*>())
rh->updateResources();
emit changed();
return true;
}
示例3: open
bool FormWindowEditor::open(const QString &fileName)
{
if (Designer::Constants::Internal::debug)
qDebug() << "FormWindowEditor::open" << fileName;
QDesignerFormWindowInterface *form = d->m_file.formWindow();
QTC_ASSERT(form, return false);
if (fileName.isEmpty()) {
setDisplayName(tr("untitled"));
return true;
}
const QFileInfo fi(fileName);
const QString absfileName = fi.absoluteFilePath();
QFile file(absfileName);
if (!file.open(QIODevice::ReadOnly|QIODevice::Text))
return false;
form->setFileName(absfileName);
const QString contents = QString::fromUtf8(file.readAll());
form->setContents(contents);
file.close();
if (!form->mainContainer())
return false;
form->setDirty(false);
syncXmlEditor(contents);
setDisplayName(fi.fileName());
d->m_file.setFileName(absfileName);
if (Internal::ResourceHandler *rh = qFindChild<Designer::Internal::ResourceHandler*>(form))
rh->updateResources();
emit changed();
return true;
}