当前位置: 首页>>代码示例>>C++>>正文


C++ QDesignerFormWindowInterface::setContents方法代码示例

本文整理汇总了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;
}
开发者ID:OnlineCop,项目名称:qt-creator,代码行数:35,代码来源:formwindoweditor.cpp

示例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;
}
开发者ID:aizaimenghuangu,项目名称:QtTestor,代码行数:47,代码来源:formwindoweditor.cpp

示例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;
}
开发者ID:NoobSaibot,项目名称:qtcreator-minimap,代码行数:40,代码来源:formwindoweditor.cpp


注:本文中的QDesignerFormWindowInterface::setContents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。