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


C++ QTextBrowser::resize方法代码示例

本文整理汇总了C++中QTextBrowser::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextBrowser::resize方法的具体用法?C++ QTextBrowser::resize怎么用?C++ QTextBrowser::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QTextBrowser的用法示例。


在下文中一共展示了QTextBrowser::resize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: showSource

void ArthurFrame::showSource()
{
    // Check for existing source
    if (findChild<QTextBrowser *>())
        return;

    QString contents;
    if (m_sourceFileName.isEmpty()) {
        contents = QString("No source for widget: '%1'").arg(objectName());
    } else {
        QFile f(m_sourceFileName);
        if (!f.open(QFile::ReadOnly))
            contents = QString("Could not open file: '%1'").arg(m_sourceFileName);
        else
            contents = f.readAll();
    }

    contents.replace('&', "&amp;");
    contents.replace('<', "&lt;");
    contents.replace('>', "&gt;");

    QStringList keywords;
    keywords << "for " << "if " << "switch " << " int " << "#include " << "const"
             << "void " << "uint " << "case " << "double " << "#define " << "static"
             << "new" << "this";

    foreach (QString keyword, keywords)
        contents.replace(keyword, QLatin1String("<font color=olive>") + keyword + QLatin1String("</font>"));
    contents.replace("(int ", "(<font color=olive><b>int </b></font>");

    QStringList ppKeywords;
    ppKeywords << "#ifdef" << "#ifndef" << "#if" << "#endif" << "#else";

    foreach (QString keyword, ppKeywords)
        contents.replace(keyword, QLatin1String("<font color=navy>") + keyword + QLatin1String("</font>"));

    contents.replace(QRegExp("(\\d\\d?)"), QLatin1String("<font color=navy>\\1</font>"));

    QRegExp commentRe("(//.+)\\n");
    commentRe.setMinimal(true);
    contents.replace(commentRe, QLatin1String("<font color=red>\\1</font>\n"));

    QRegExp stringLiteralRe("(\".+\")");
    stringLiteralRe.setMinimal(true);
    contents.replace(stringLiteralRe, QLatin1String("<font color=green>\\1</font>"));

    QString html = contents;
    html.prepend("<html><pre>");
    html.append("</pre></html>");

    QTextBrowser *sourceViewer = new QTextBrowser(0);
    sourceViewer->setWindowTitle("Source: " + m_sourceFileName.mid(5));
    sourceViewer->setParent(this, Qt::Dialog);
    sourceViewer->setAttribute(Qt::WA_DeleteOnClose);
    sourceViewer->setLineWrapMode(QTextEdit::NoWrap);
    sourceViewer->setHtml(html);
    sourceViewer->resize(600, 600);
    sourceViewer->show();
}
开发者ID:Andreas665,项目名称:qt,代码行数:59,代码来源:arthurwidgets.cpp

示例2: main

int main(int argc, char **argv)
{
    QApplication app(argc, argv);

//! [0]
    QTextBrowser browser;
    QColor linkColor(Qt::red);
    QString sheet = QString::fromLatin1("a { text-decoration: underline; color: %1 }").arg(linkColor.name());
    browser.document()->setDefaultStyleSheet(sheet);
//! [0]
    browser.setSource(QUrl("../../../html/index.html"));
    browser.resize(800, 600);
    browser.show();

    return app.exec();
}
开发者ID:Fale,项目名称:qtmoko,代码行数:16,代码来源:main.cpp

示例3: showLog

/*!
    Shows the application log.
    \todo Write some sort of log viewer.
*/
void MvdMainWindow::showLog()
{
    QFileInfo fi(paths().logFile());
    QFile file(fi.absoluteFilePath());
    if (!file.open(QIODevice::ReadOnly)) {
        QMessageBox::warning(this, MVD_CAPTION, tr("Failed to open the log file."));
        return;
    }

    QTextBrowser *viewer = new QTextBrowser;
    viewer->setWindowFlags(Qt::Tool);
    viewer->setWindowModality(Qt::NonModal);
    viewer->resize(640, 480);

    new MvdLogSyntaxHighlighter(viewer->document());

    QTextStream stream(&file);
    QString text = stream.readAll();

    viewer->setPlainText(text);
    viewer->show();
}
开发者ID:hippydream,项目名称:movida,代码行数:26,代码来源:mainwindow.cpp


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