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


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

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


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

示例1: file

TupAbout::TupAbout(QWidget *parent) : TabDialog(Cancel, parent)
{
    // SQA: Check if these instructions are doing something for real
    setWindowIcon(QIcon(THEME_DIR + "icons" + QDir::separator() + "about.png"));
    setWindowTitle(tr("About Tupi"));    
    setFixedSize(525, 458);

    QStringList path;
#ifdef Q_OS_WIN32
    QString resources = SHARE_DIR + "help" + QDir::separator();
#else
	QString resources = SHARE_DIR + "data" + QDir::separator() + "help" + QDir::separator();
#endif
    path << resources + "css";
    path << resources + "images";
	
    QString lang = "en";
    if (QString(QLocale::system().name()).length() > 1)
        lang = QString(QLocale::system().name()).left(2);

    Qt::WindowFlags flags = 0;
    flags = Qt::Dialog;
    flags |= Qt::CustomizeWindowHint;
    setWindowFlags(flags);

    // Credits Tab

    QDomDocument doc;
    QString creditsFile = DATA_DIR + "credits.xml";
    QFile file(creditsFile);
    QString creditsText;

    if (!file.open(QIODevice::ReadOnly)) {
        #ifdef K_DEBUG
            QString msg = "TupAbout::TupAbout() - Fatal Error: Can't open \"credits.xml\" file";
            #ifdef Q_OS_WIN32
                qDebug() << msg;
            #else
                tError() << msg;
            #endif
        #endif
        return;
    }

    if (!doc.setContent(&file)) {
        #ifdef K_DEBUG
            QString msg = "TupAbout::TupAbout() - Fatal Error: File \"credits.xml\" is corrupt!";
            #ifdef Q_OS_WIN32
                qDebug() << msg;
            #else
                tError() << msg;
            #endif
        #endif
        file.close();
        return;
    }
    file.close();

    QDomElement docElem = doc.documentElement();
    QDomNode n = docElem.firstChild();

    while (!n.isNull()) {
           QDomElement e = n.toElement();
           if (!e.isNull()) {
               if (e.tagName() == "credits")
                   creditsText = e.text();
           }
           n = n.nextSibling();
    }

    m_credits = new TAnimWidget(QPixmap(THEME_DIR + QDir::separator() + "images" + QDir::separator() + "credits.png"), creditsText);
    addTab(m_credits, tr("Credits"));

    QPalette pal = m_credits->palette();
    pal.setColor(QPalette::Foreground, QColor(50, 50, 50, 255));
    m_credits->setPalette(pal);
    m_credits->setFont(QFont("verdana", 24));

    // Acknowledgment Tab 

    QString sponsorFile = QString() + "help" + QDir::separator() + lang + QDir::separator() + "thanks.html";
#ifdef Q_OS_WIN32
    QString sponsorPath = SHARE_DIR + sponsorFile;
#else
    QString sponsorPath = SHARE_DIR + "data" + QDir::separator() + sponsorFile;
#endif
    QTextBrowser *sponsorsText = new QTextBrowser;
    sponsorsText->setSearchPaths(path);
    sponsorsText->setOpenExternalLinks(true);
    sponsorsText->setSource(QUrl::fromLocalFile(sponsorPath));
    sponsorsText->moveCursor(QTextCursor::Start);

    addTab(sponsorsText, tr("Thanks"));

    // Tupi Description Tab 

    QString tupiFile = QString() + "help" + QDir::separator() + lang + QDir::separator() + "tupi_short.html";
#ifdef Q_OS_WIN32
    QString tupiPath = SHARE_DIR + tupiFile;
#else
//.........这里部分代码省略.........
开发者ID:KDE,项目名称:tupi,代码行数:101,代码来源:tupabout.cpp


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